Predict the Output
Merging Two Lists
Two sorted lists, two pointers. What is printed when the loop ends? (Careful: the leftovers are not appended.)1a, b = [1, 4, 7], [2, 3, 9]
2i = j = 0
3out = []
4while i < len(a) and j < len(b):
5 if a[i] < b[j]:
6 out.append(a[i])
7 i += 1
8 else:
9 out.append(b[j])
10 j += 1
11print(out, i, j)