Question DSA-ARR-0045
MediumWhat is the output of this code?
a = [0, 1, 0, 3, 12]
j = 0
for i in range(len(a)):
if a[i] != 0:
a[i], a[j] = a[j], a[i]
j += 1
print(a)
- A.
[1, 0, 3, 12, 0]
- B.
[0, 0, 1, 3, 12]
- C.
Sign up free to see the answer and a step-by-step explanation.