Skip to content

Commit 73e924f

Browse files
committed
Time: 364 ms (47.02%), Space: 17.8 MB (36.47%) - LeetHub
1 parent 70f64fa commit 73e924f

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

0055-jump-game/0055-jump-game.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
class Solution:
2+
def canJump(self, nums: List[int]) -> bool:
3+
max_reach = 0
4+
for i, num in enumerate(nums):
5+
if i > max_reach:
6+
return False
7+
max_reach = max(max_reach, i + num)
8+
return max_reach >= len(nums) - 1

0 commit comments

Comments
 (0)