题目
约束
题解
class Solution {
public:
bool canJump(vector<int>& nums) {
int n = nums.size();
int rightmost = 0;
for (int i = 0; i < n; ++i) {
if (i <= rightmost) {
rightmost = max(rightmost, i + nums[i]);
if (rightmost >= n - 1) {
return true;
}
}
}
return false;
}
};
标签:return,nums,55,题解,int,LeetCode,贪心
From: https://www.cnblogs.com/chuixulvcao/p/17113236.html