标签:res long seq size int enc code asi style
class Solution { public: int lengthOfLIS(vector<int>& nums) { int length = nums.size(); if(length <= 0) return 0; vector<int> result(length); for(int i = 0;i < length;i++) result[i] = 1; for(int i = 1;i < length;i++){ int max_sum = 1; for(int j = i-1;j >= 0;j--){ if(nums[i] > nums[j]){ int num = result[j] + 1; if(num > max_sum) max_sum = num; } } result[i] = max_sum; } int max = 1; for(int i = 0;i < length;i++){ if(result[i] > max) max = result[i]; } return max; } };
leetcode300. Longest Increasing Subsequence 最长递增子序列
标签:res long seq size int enc code asi style
原文地址:https://www.cnblogs.com/ymjyqsx/p/9567417.html