Skip to content

Commit 6d457c7

Browse files
authored
Create 55. Jump Game
1 parent 6006417 commit 6d457c7

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

55. Jump Game

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

0 commit comments

Comments
 (0)