Question DSA-GRDY-0014
HardWhat is the output of this code?
a = [2, 3, 1, 1, 4]
jumps = end = far = 0
for i in range(len(a) - 1):
far = max(far, i + a[i])
if i == end:
jumps += 1
end = far
print(jumps)
- A.
1
- B.
3
- C.
Sign up free to see the answer and a step-by-step explanation.