Open Ni-Guvara opened 1 year ago
class Solution { public: bool canJump(vector<int>& nums) { int right = nums.size() - 2; int cnt = 0; vector<bool> recd(nums.size() , false); recd[right + 1] = true; while(right >= 0) { if(nums[right] > 0 && cnt == 0) { recd[right] = recd[right + 1]; cnt = 0; } else { ++cnt; if(nums[right] >= cnt) { recd[right] = recd[right + cnt]; cnt = 0; } } --right; } return recd[0]; } };