Link: 55. Jump Game - Medium

Question

Restate the problem


Method 1
Method 2 - Greedy

Method - Greedy

Approach

(discussed at lease two approach?)

Complexity

Edge Case

Code

class Solution:
    def canJump(self, nums: List[int]) -> bool:
        n = len(nums)
 
        farthest = 0
        for i, step in enumerate(nums):
            if i > farthest:
                return False
            
            else:
                farthest = max(farthest, i + step)
                if farthest >= n - 1:
                    return True

History