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