Java 4 lines solution


  • 0
        public boolean canJump(int[] nums) {
            int reach = 0;
            for (int i = 0; i < nums.length; i++) 
                reach = i > reach ? reach : Math.max(reach, i + nums[i]);
            return reach >= nums.length - 1;
        }
    

Log in to reply
 

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