Question DSA-SORT-0017
HardWhat is the output of this code?
a = [6, 2, 5, 1, 3]
pivot = a[-1]
i = 0
for j in range(len(a) - 1):
if a[j] < pivot:
a[i], a[j] = a[j], a[i]
i += 1
a[i], a[-1] = a[-1], a[i]
print(a)
- A.
[1, 2, 3, 5, 6]
- B.
[2, 3, 1, 5, 6]
- C.
Sign up free to see the answer and a step-by-step explanation.