Concise C solution and easy to understand 4ms,5 lines


  • 0
    H
    bool canJump(int* nums, int numsSize) {
        int farthest = nums[0];
        for(int i = 0; i < numsSize && farthest >= i; i++)
            if(nums[i] + i > farthest)
                farthest = nums[i] + i;
        return farthest >= numsSize -1;
    }

Log in to reply
 

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