Test cases are not complete


  • 0
    J

    the following code will pass the OJ.

    class Solution {
    public:
    	bool canJump(int A[], int n) {
    		if (n <= 1)
    			return true;
    		int next = 0;
    		while (next < n - 1)
    		{
    			if (A[next] == 0)
    				return false;
    			next += A[next];
    		}
    		return next >= n - 1;
    	}
    };
    

    But consider a case {2, 5, 0, 0}. My code return false, but it should return true;


  • 0

    Thanks, I've added your test case.


  • 0
    S
    This post is deleted!

Log in to reply
 

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