Skip to content

Commit d745133

Browse files
authored
Create 45-Jump-Game-II.py
1 parent e3f2ac6 commit d745133

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

45-Jump-Game-II.py

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
class Solution:
2+
def jump(self, nums: List[int]) -> int:
3+
l, r = 0, 0
4+
res = 0
5+
while r < (len(nums) - 1):
6+
maxJump = 0
7+
for i in range(l, r + 1):
8+
maxJump = max(maxJump, i + nums[i])
9+
l = r + 1
10+
r = maxJump
11+
res += 1
12+
return res

0 commit comments

Comments
 (0)