Simple java solution

  • 3
    public class Solution {
        public boolean canJump(int[] nums) {
            int lastIndex=nums.length-1;
            for (int i=nums.length-2;i>=0;i--) {if (nums[i]>=(lastIndex-i)) lastIndex=i;}
            return lastIndex==0;

    Check from lastIndex of the array. If any place can reach the lastIndex, update the lastIndex.

Log in to reply

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