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!
Uppgift
Swipe to start coding
- Set while loop to work while the
left
is lower than theright
. - Set the
middle
variable. Themiddle
equals the(left + right) // 2
. - Set the condition if the middle element is greater or equals the
x
. - Update the
left
. Theleft
equals themiddle + 1
. - Create an empty array to fill it with values to test the function.
- Set for loop to work with the
nums
array. - Append the
i
to theintersection_nums
. - Print the
intersection_nums
.
Lösning
Var allt tydligt?
Tack för dina kommentarer!
Avsnitt 2. Kapitel 2
single
Fråga AI
Fråga AI
Fråga vad du vill eller prova någon av de föreslagna frågorna för att starta vårt samtal
Awesome!
Completion rate improved to 14.29
Arrays Intersection
Svep för att visa menyn
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!
Uppgift
Swipe to start coding
- Set while loop to work while the
left
is lower than theright
. - Set the
middle
variable. Themiddle
equals the(left + right) // 2
. - Set the condition if the middle element is greater or equals the
x
. - Update the
left
. Theleft
equals themiddle + 1
. - Create an empty array to fill it with values to test the function.
- Set for loop to work with the
nums
array. - Append the
i
to theintersection_nums
. - Print the
intersection_nums
.
Lösning
Var allt tydligt?
Tack för dina kommentarer!
Awesome!
Completion rate improved to 14.29Avsnitt 2. Kapitel 2
single