leetcode-----45. 跳跃游戏 II

代码

class Solution {
public:
    int jump(vector<int>& nums) {
        int n = nums.size();
        vector<int> f(n);

        for (int i = 1, j = 0; i < n; ++i) {
            while (j + nums[j] < i) j++;
            f[i] = f[j] + 1;
        }
        return f[n - 1];
    }
};
posted @ 2020-07-07 08:57  景云ⁿ  阅读(50)  评论(0编辑  收藏  举报