Arrays Intersection
Now we will try to create a program that will find the intersection of the 2 arrays.
Look at the explanation of the task! How does it work?
Use hints if needed! Be careful with the tabulation!
Tehtävä
Swipe to start coding
- Set while loop to work while the
leftis lower than theright. - Set the
middlevariable. Themiddleequals the(left + right) // 2. - Set the condition if the middle element is greater or equals the
x. - Update the
left. Theleftequals themiddle + 1. - Create an empty array to fill it with values to test the function.
- Set for loop to work with the
numsarray. - Append the
ito theintersection_nums. - Print the
intersection_nums.
Ratkaisu
Oliko kaikki selvää?
Kiitos palautteestasi!
Osio 2. Luku 2
single
Kysy tekoälyä
Kysy tekoälyä
Kysy mitä tahansa tai kokeile jotakin ehdotetuista kysymyksistä aloittaaksesi keskustelumme
Suggested prompts:
Tiivistä tämä luku
Explain code
Explain why doesn't solve task
Awesome!
Completion rate improved to 14.29
Arrays Intersection
Pyyhkäise näyttääksesi valikon
Now we will try to create a program that will find the intersection of the 2 arrays.
Look at the explanation of the task! How does it work?
Use hints if needed! Be careful with the tabulation!
Tehtävä
Swipe to start coding
- Set while loop to work while the
leftis lower than theright. - Set the
middlevariable. Themiddleequals the(left + right) // 2. - Set the condition if the middle element is greater or equals the
x. - Update the
left. Theleftequals themiddle + 1. - Create an empty array to fill it with values to test the function.
- Set for loop to work with the
numsarray. - Append the
ito theintersection_nums. - Print the
intersection_nums.
Ratkaisu
Oliko kaikki selvää?
Kiitos palautteestasi!
Osio 2. Luku 2
single