bool canJump(int A[], int n) {
int lastIndex = n - 1;
int index = n - 1;
while (index >= 0)
{
if (A[index] >= (lastIndex - index))
{
lastIndex = index;
}
index--;
}
if (lastIndex == 0)
{
return true;
}
else
{
return false;
}
}
bool canJump(int A[], int n) {
int canJumpPosition = n - 1;
int curPosition = n - 1;
while (curPosition >= 0){
if ((canJumpPosition - curPosition) <= A[curPosition]){
canJumpPosition = curPosition;
}
curPosition--;
}
if (canJumpPosition == 0){
return true;
}
else{
return false;
}
}
bool canJump(int A[], int n) {
int canJumpPosition = n - 1;
int curPosition = n - 1;
while (curPosition >= 0) {
if ((canJumpPosition - curPosition) <= A[curPosition]) {
canJumpPosition = curPosition;
}
curPosition--;
}
if (canJumpPosition == 0) {
return true;
}
else {
return false;
}
}