原文链接:Leetcode 300. 最长递增子序列
class Solution {
public:int lengthOfLIS(vector<int>& nums) {int n = nums.size();// dp[i]表示以nums[i]结尾的严格递增子序列的长度int dp[n];dp[0] = 1;int res = 1;for (int i = 1; i < n; i++) {dp[i] = 1;for (int j = 0; j < i; j++) {if (nums[i] > nums[j]) {dp[i] = max(dp[j] + 1, dp[i]);}}res = max(res, dp[i]);}return res;}
};
贪心 + 二分查找
待补充