#55
Jump Game
medium· Greedyruns: 0You are given an integer array nums. You are initially positioned at the array's first index, and each element nums[i] represents your maximum jump length at that position. Return true if you can reach the last index, otherwise false.
sign in to paste and practice your own solution
wpm 0acc 100%time 0:000 / 226
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 goal == 0
click the box to focus · tab inserts 4 spaces · backspace to correct · esc to pause
desktop only
codedrill is a typing game and needs a real keyboard. open this on a laptop or desktop to practice.
you can still browse problems and sections from your phone.