Question DSA-TP-0064
HardWhat is the output of this code?
a = [1, 1, 2, 2, 2, 3]
i = 0
for x in a:
if i < 2 or x != a[i - 2]:
a[i] = x; i += 1
print(i, a[:i])
- A.
6 [1, 1, 2, 2, 2, 3]
- B.
4 [1, 1, 2, 3]
- C.
Sign up free to see the answer and a step-by-step explanation.