Skip to content

Instantly share code, notes, and snippets.

@kanrourou
Created December 23, 2014 07:07
Show Gist options
  • Save kanrourou/1b12ba0ce2963a0c648f to your computer and use it in GitHub Desktop.
Save kanrourou/1b12ba0ce2963a0c648f to your computer and use it in GitHub Desktop.
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