track backwards 1~2ms


  • 0
    C

    public class Solution {

    public boolean canJump(int[] nums) {
        int l=nums.length-1;
        for (int i=nums.length-2; i>0;i--) {
            if(i+nums[i]>=l) l=i;
        }
        return nums[0]>=l;
    }
    

    }


Log in to reply
 

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