Skip to content

Commit fb9fd2f

Browse files
Create 55. Jump Game.cpp
this is the solution
1 parent 499baf9 commit fb9fd2f

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

55. Jump Game.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
class Solution {
2+
public:
3+
bool canJump(vector<int>& nums) {
4+
int maxDist = 0;
5+
for(int i=0;i<nums.size();i++){
6+
if(i>maxDist) return false;
7+
maxDist = std::max(maxDist,i+nums[i]);
8+
}
9+
return true;
10+
}
11+
};

0 commit comments

Comments
 (0)