Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool possible = false;
- int len;
- bool canJump(vector<int>& nums) {
- len = nums.size();
- if(len <= 1) return true;
- find(nums, len - 2, len - 1);
- return possible;
- }
- void find(vector<int>& nums, int idx, int last){
- if(idx == 0) {
- if(idx + nums[idx] >= last) possible = true;
- return;
- }
- if(idx + nums[idx] >= last) {
- find(nums, idx - 1, idx);
- } else{
- find(nums, idx - 1, last);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement