小旭讲解 基础算法系列 - 什么是动态规划?
小旭讲解 基础算法系列 - 什么是动态规划?

视频

代码

class Solution {
public:
    int lengthOfLIS(vector<int>& nums) {
        int n=nums.size();
        vector<int> f(n+1, 1);
        int ans=1;
        for(int i=2;i<=n;++i) {
            for(int j=i-1;j>=1;--j) {
                if(nums[i-1]>nums[j-1]) f[i]=max(f[i],f[j]+1);
            }
            ans=max(ans,f[i]);
        }
        return ans;
    }
};
欢迎分享,引用。若转载,请联系我,谢谢配合。
本文地址:https://qoogle.top/xiaoxu-tutorial-bas-what-is-dp/
5 1 vote
Article Rating
Subscribe
提醒
guest
1 评论
Newest
Oldest Most Voted
Inline Feedbacks
View all comments

Thanks for your strategies. One thing really noticed is that often banks plus financial institutions know the dimensions and spending patterns of consumers plus understand that plenty of people max outside their cards around the trips. They correctly take advantage of this real fact and then start flooding a person’s inbox plus snail-mail box by using hundreds of no interest APR credit cards offers shortly when the holiday season closes. Knowing that when you are like 98% in the American general public, you’ll get at the one opportunity to consolidate financial debt and switch balances towards 0 rate credit cards. nmmllno https://headachemedi.com – medication for severe headaches