bool canJump(vector<int>& nums)
{
int idx = nums.size() - 1;
if (idx == 0)
return true;
for (int i = idx - 1; i >= 0; i--)
{
if (nums[i] + i >= idx)
idx = i;
}
return idx == 0;
}
'코딩테스트 > LeetCode' 카테고리의 다른 글
[LeetCode] 151. Reverse Words in a String (0) | 2024.07.02 |
---|---|
[LeetCode] 45. Jump Game II (0) | 2024.06.17 |
[LeetCode] 136. Single Number (0) | 2024.06.13 |
[LeetCode] 1 - Two Sum (0) | 2024.04.03 |
[LeetCode] 6 - Zigzag Conversion (0) | 2024.04.03 |