JavaScript solution! Easy to understand!


  • 0
    var canJump = function(nums) {
        var lastIndex = nums.length - 1;
        for (var i = nums.length - 2; i >= 0; --i) {
            if (i + nums[i] >= lastIndex) {
                //that means from nums[i] you can jump to nums[lastIndex]
                lastIndex = i;
            }
        }
        return lastIndex === 0;
    };
    

Log in to reply
 

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