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!
Tâche
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
.
Solution
Tout était clair ?
Merci pour vos commentaires !
Section 2. Chapitre 2
single
Demandez à l'IA
Demandez à l'IA
Posez n'importe quelle question ou essayez l'une des questions suggérées pour commencer notre discussion
Suggested prompts:
Résumer ce chapitre
Expliquer le code dans file
Expliquer pourquoi file ne résout pas la tâche
Awesome!
Completion rate improved to 14.29
Arrays Intersection
Glissez pour afficher le menu
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!
Tâche
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
.
Solution
Tout était clair ?
Merci pour vos commentaires !
Awesome!
Completion rate improved to 14.29Section 2. Chapitre 2
single