Possibly the easiest question on leetcode. Simple solution using Java linear time constant space


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

Log in to reply
 

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