Jump Game 2021-06-11 20:33

Problem Description

public boolean canJump(int[] nums) {
    int length = nums.length;
    if (length == 1) {
        return true;
    }
    int cur = nums[0];
    int i;
    for (i = 1; i < length && cur > 0; i++) {
        cur--;
        if (nums[i] > cur) {
            cur = nums[i];
        }
    }
    return i == length;
}
Runtime Memory
2 ms 40 MB

henryxi leetcode list

EOF