Very simple Python solution


  • 0
    H
    class Solution(object):
        def canJump(self, nums):
            """
            :type nums: List[int]
            :rtype: bool
            """
            p = 0
            for i in xrange(len(nums)-1):
                if p >= i:
                    p = max(p, i+nums[i])
            
            if p >= len(nums)-1:
                return True
            else:
                return False

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.