您的位置:首页 > 其它

LeetCode-Jump Game II

2013-08-03 22:24 239 查看
class Solution {
public:
int jump(int A[], int n) {
// Start typing your C/C++ solution below
// DO NOT write int main() function
int end = n - 1;
int steps = 0;
while (end > 0)
{
for (int i = 0; i < end; ++i)
{
if (A[i] >= end - i)
{
++steps;
end = i;
break;
}
}
}
return steps;
}
};
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: