Question DSA-ARR-0013
MediumWhat is the output of this code?
a = [5, 3, 5, 2, 5, 5, 6]
cand, cnt = None, 0
for x in a:
if cnt == 0:
cand = x
cnt += 1 if x == cand else -1
print(cand)
- A.
2
- B.
5
- C.
Sign up free to see the answer and a step-by-step explanation.