From f9a7af59de3c8bcee7c63a2d03af09da703ebaf3 Mon Sep 17 00:00:00 2001 From: ayusharma03 <49690065+ayusharma03@users.noreply.github.com> Date: Wed, 12 Oct 2022 20:26:32 +0530 Subject: [PATCH] Create jumpgame.py --- Jump Game 1/jumpgame.py | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 Jump Game 1/jumpgame.py diff --git a/Jump Game 1/jumpgame.py b/Jump Game 1/jumpgame.py new file mode 100644 index 0000000..fa196c4 --- /dev/null +++ b/Jump Game 1/jumpgame.py @@ -0,0 +1,7 @@ +class Solution: + def canJump(self, nums: List[int]) -> bool: + goal = len(nums) - 1 + for i in range(len(nums)-1,-1,-1): + if i + nums[i] >= goal: + goal = i + return True if goal == 0 else False