Problem A
Swipe to start coding
The task is to merge given sorted arrays arr1
and arr2
. Do not use ready code from Merge Sort Algorithm.
How to merge: you have two sorted arrays arr1
and arr2
, let’s set pointers p1
and p2
at the beginning of each of them (p1=0
, p2=0
).
Compare current values: if arr1[p1] < arr2[p2]
, then put arr1[p1]
to temp
and increase p1
by 1. Else do the same for p2
.
If one of the pointers reaches max possible value (out of bounds), you can not check, and store all rest elements from another array.
Do the following until p1 < len(arr1) or p2 < len(arr2)
.
Lösung
Danke für Ihr Feedback!
single
Fragen Sie AI
Fragen Sie AI
Fragen Sie alles oder probieren Sie eine der vorgeschlagenen Fragen, um unser Gespräch zu beginnen
Zusammenfassen Sie dieses Kapitel
Code in file erklären
Erklären, warum file die Aufgabe nicht löst
Awesome!
Completion rate improved to 7.69
Problem A
Swipe um das Menü anzuzeigen
Swipe to start coding
The task is to merge given sorted arrays arr1
and arr2
. Do not use ready code from Merge Sort Algorithm.
How to merge: you have two sorted arrays arr1
and arr2
, let’s set pointers p1
and p2
at the beginning of each of them (p1=0
, p2=0
).
Compare current values: if arr1[p1] < arr2[p2]
, then put arr1[p1]
to temp
and increase p1
by 1. Else do the same for p2
.
If one of the pointers reaches max possible value (out of bounds), you can not check, and store all rest elements from another array.
Do the following until p1 < len(arr1) or p2 < len(arr2)
.
Lösung
Danke für Ihr Feedback!
Awesome!
Completion rate improved to 7.69single