Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution {
- public:
- int dp[10010];
- int jump(vector<int>& nums) {
- int n = nums.size();
- dp[0] = 0;
- int pre = 0, cur = 1;
- while(cur < n){
- while(cur - pre > nums[pre])
- pre ++;
- dp[cur] = dp[pre] + 1;
- cur ++;
- }
- return dp[n-1];
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement