function jump(nums)
jumps := 0
currentEnd := 0
furthest := 0
for i from 0 to length of nums - 2
furthest := max(furthest, i + nums[i])
if i = currentEnd then
jumps := jumps + 1
currentEnd := furthest
return jumps
Time: . Space: .
The code
function jump(nums)
jumps := 0
currentEnd := 0
furthest := 0
for i from 0 to length of nums - 2
furthest := max(furthest, i + nums[i])
if i = currentEnd then
jumps := jumps + 1
currentEnd := furthest
return jumps
Time: . Space: .