Jump Game II LeetCode solution in Python

1
# Runtime: 305 ms (Top 40.77%) | Memory: 15 MB (Top 90.04%)
2
class Solution(object):
3
def jump(self, nums):
4
ans = l = r = 0
5

6
while r < len(nums) - 1:
7
farthestJump = 0
8

9
for i in range(l, r + 1):
10
farthestJump = max(farthestJump, i + nums[i])
11

12
l = r + 1
13
r = farthestJump
14
ans += 1
15

16
return ans

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0