My c solution 7 ms


  • 1
    B
    bool canJump(int* nums, int numsSize) {
        int max_position = 0;
        for (int i = 0; i < numsSize && numsSize > max_position; ++i) {
            if (i > max_position) return false;
            if (i + nums[i] > max_position) max_position = i + nums[i];
        }
        return true;
    }

Log in to reply
 

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