Short and easy solution


  • 0
    P
    public class Solution {
    public boolean canJump(int[] nums) {
        if ( nums == null ) return false;
        
        int reach = 0;
        
        for ( int i = 0 ; i < nums.length; i++ ) { 
            if ( reach < i ) return false;
            reach = Math.max(reach, nums[i] + i);
        }
        
        return true;
        
    }

Log in to reply
 

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