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