代码:
class Solution
{
public:
bool canJump(int A[], int n)
{
for (int i=0, bound=0; i <= bound; ++ i)
{
bound = max(A[i]+i, bound);
if (bound >= n-1)
{
return true;
}
}
return false;
}
};
突然发现leetcode的题目顺序好像会动态变化的... so weird!