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