跳跃游戏

class Solution {
public:
/**
* @param A: A list of integers
* @return: The boolean answer
*/
bool func(vector<int> A, int i, int size)
{
if (i >= size - 1)
return true;

int t = A[i];
while (t > 0)
{
if (func(A, t + i, size))
return true;
t--;
}
return false;
}

bool canJump(vector<int> A) {
// write you code here
int size = A.size();
int i = 0;
return func(A, i, size);

}
};

posted @ 2017-08-28 19:15  MAC10  阅读(120)  评论(1编辑  收藏  举报