300. 最长上升子序列
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 class Solution 2 { 3 public: 4 int lengthOfLIS(vector<int>& nums) 5 { 6 int n=nums.size(); 7 if(n==0)return 0; 8 if(n==1)return 1; 9 10 vector<int> dp(n,1); 11 int res=0; 12 for(int i=0;i<n;++i) 13 { 14 for(int j=0;j<i;++j) 15 { 16 if(nums[j]<nums[i]) 17 { 18 dp[i]=max(dp[i],dp[j]+1); 19 } 20 } 21 res=max(res,dp[i]); 22 } 23 return res; 24 } 25 };