Short n Simple Python O(n) time O(1) space

  • 0
        def canJump(self, nums):
            if len(nums) < 2: return True
            i = mx = 0
            while i <= mx:
                mx, i = max(mx, i+nums[i]), i + 1
                if mx >= len(nums)-1: return True
            return False

Log in to reply

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