标签:子序列 vector pre code bsp out min 最长上升子序列 amp
1 class Solution 2 { 3 public: 4 int lengthOfLIS(vector<int>& nums) 5 { 6 if(nums.size() == 0) return 0; 7 int n = nums.size(); 8 int res = INT_MIN; 9 vector<int> dp(n,1); 10 11 for(int i = 0;i < n;i ++) 12 { 13 for(int j = 0;j < i;j ++) 14 { 15 if(nums[i] > nums[j] && dp[i] < dp[j] + 1) dp[i] = dp[j] + 1; 16 } 17 if(res < dp[i]) res = dp[i]; 18 } 19 //for(auto a : dp) cout << a << " "; 20 return res; 21 } 22 };
标签:子序列 vector pre code bsp out min 最长上升子序列 amp
原文地址:https://www.cnblogs.com/yuhong1103/p/12523614.html