https://leetcode.com/problems/jump-game/?envType=study-plan-v2&envId=top-interview-150
class Solution {
public:
bool canJump(vector<int>& nums) {
int mx = 0;
for (int i = 0; i < nums.size(); i++) {
if (i > mx) return false;
mx = max(mx, i + nums[i]);
}
return true;
}
};
Time Complexity: O(n)
Space: O(1)
普通正常題目