Skip to content

Commit

Permalink
이슈 #446에서 솔루션 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Dec 5, 2024
1 parent ff40e7f commit 6d43ed9
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions LeetCode/Jump_Game.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
class Solution {
public:
bool canJump(vector<int>& nums) {
int maxReach = 0;

for (int i = 0; i < nums.size(); i++) {
if (maxReach < i) {
return false;
}

maxReach = max(maxReach, i + nums[i]);

if (maxReach >= nums.size() - 1) {
return true;
}
}

return false;
}
};

0 comments on commit 6d43ed9

Please sign in to comment.