Javascript solution using step counter / greedy


  • 0
    R
    var canJump = function(nums) {
        var size = nums.length;
        var step = nums[0];
        for(var i = 1; i < size; ++i) {
            step--;
            if(step < 0) {
                return false;
            }
            if(nums[i]>step) {
                step = nums[i];
            }
        }
        return true;
    };
    

Log in to reply
 

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