Testcase is not perfect for this problem.


  • 0

    The code is wrong but when I submitted, it was accepted.

    public class Solution {
        public boolean canJump(int[] nums) {
            int max = 0, index = 0;
            for (int i = 0; i < nums.length - 1 && i >= index; ) {
                if (i + nums[i] > max) {
                    max = i + nums[i];
                    index = i;
                    i = max;
                } else {
                    i--;
                }
            }
            return max >= nums.length - 1;
        }
    }
    

    Testcase: [3, 0, 8, 2, 0, 0, 1]
    Your answer: false
    Expected answer: true


  • 0

    Thanks, I've just published your test case.


  • 0
    Z
    This post is deleted!

Log in to reply
 

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