mirror of
https://github.com/20kaushik02/leetcode-gulag.git
synced 2026-01-25 07:34:05 +00:00
let's try this again shall we
problems 1->10 of LC150
This commit is contained in:
15
55-jump-game/soln.py
Normal file
15
55-jump-game/soln.py
Normal file
@@ -0,0 +1,15 @@
|
||||
def canJump(self, nums: list[int]) -> bool:
|
||||
n = len(nums)
|
||||
if n == 1:
|
||||
return True
|
||||
if nums[0] == 0:
|
||||
return False
|
||||
dp = [False] * n
|
||||
dp[n - 1] = True
|
||||
|
||||
for idx in range(n - 2, -1, -1):
|
||||
for reach in range(0, nums[idx]):
|
||||
if dp[idx + reach + 1] == True:
|
||||
dp[idx] = True
|
||||
break
|
||||
return dp[0]
|
||||
Reference in New Issue
Block a user