Straightforward Java implementation (beats 96%)


  • 0
    K
    public boolean canJump(int[] nums) {
        if(nums.length<=1)
            return true;
        int d = 1;
        for(int i=nums.length-2;i>=0;i--) {
            if(nums[i]>=d) d = 1;
            else d++;
        }
        return (d==1);
    }

Log in to reply
 

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