300. 最长递增子序列
作者:互联网
一开始想的是深度遍历加剪枝,然后就时间超时了,判断能否加入最长递增子序列,代码如下:
查看代码
class Solution {
public:
int lengthOfLIS(vector<int>& nums) {
int result = 0;
int minn = INT_MIN;
int temp = 0;
result = max_son(nums ,0,minn,temp);
return result;
}
int max_son(vector<int>& nums, int place,int minn,int temp){
if(place >= nums.size()){
return 0;
}
int result = max_son(nums,place+1,minn,temp);
if(nums[place] > minn){
result=max(max_son(nums,place+1,nums[place],temp)+1,result);
}
return result+temp;
}
};
看了官方的贪心+二分,自己码一遍
所以超时
标签:minn,temp,nums,300,递增,int,place,result,序列 来源: https://www.cnblogs.com/jozon/p/15733840.html