Skip to content

Commit 5f9eca0

Browse files
committed
Jump Game Solution
1 parent 1d62ca4 commit 5f9eca0

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

jump-game/PDKhan.cpp

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

0 commit comments

Comments
 (0)