Skip to content

Instantly share code, notes, and snippets.

@SAgarwal-24
Forked from SuryaPratapK/Jump game
Created June 12, 2020 18:42
Show Gist options
  • Select an option

  • Save SAgarwal-24/e8afe7c21c2de2d4f12e5fa4299d35a0 to your computer and use it in GitHub Desktop.

Select an option

Save SAgarwal-24/e8afe7c21c2de2d4f12e5fa4299d35a0 to your computer and use it in GitHub Desktop.
class Solution {
public:
bool canJump(vector<int>& nums) {
int n = nums.size();
int reachable = 0;
for(int i=0;i<n;++i)
{
if(reachable < i)
return false;
reachable = max(reachable,i+nums[i]);
}
return true;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment