Linear and simple to understand


  • 0
    T
    public class Solution {
        public boolean canJump(int[] nums) {
            int n = nums.length;
            int closestJump = n-1;
            for(int i = n-2;i>=0;i--){
                if(i+nums[i]>=closestJump){
                    closestJump = i;
                }
            }
            return closestJump <= 0;
        }
    }
    

Log in to reply
 

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