Skip to content

Commit 435e438

Browse files
committed
solve : jump game
1 parent ca162fd commit 435e438

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

jump-game/samthekorean.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# TC : O(n)
2+
# SC : O(1)
3+
class Solution:
4+
def canJump(self, nums):
5+
reachable = 0
6+
for i in range(len(nums)):
7+
if i > reachable:
8+
return False
9+
reachable = max(reachable, i + nums[i])
10+
return True

0 commit comments

Comments
 (0)