public int jump(int[] nums) {
        if (nums == null) return 0;

        int maxJump = 0, lastMaxJump = 0, cnt = 0;
        for (int i = 0; i < nums.length; ++i) {
            if (i > lastMaxJump) {
                ++cnt;
                lastMaxJump = maxJump;
            }
            maxJump = Math.max(maxJump, i + nums[i]);
        }
        if (maxJump < nums.length - 1) return 0;
        return cnt;
    }