Created
December 23, 2014 07:07
-
-
Save kanrourou/1b12ba0ce2963a0c648f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Solution { | |
public boolean canJump(int[] A) { | |
if (A == null) | |
return false; | |
int len = A.length; | |
if (len == 0) | |
return false; | |
int rightBound = A[0]; | |
int i = 0; | |
while (i <= rightBound) { | |
if (i + A[i] > rightBound) | |
rightBound = i + A[i]; | |
if (rightBound >= len - 1) | |
return true; | |
i++; | |
} | |
return false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment