滴滴手撕 最长递增子序列lc300
#include
using namespace std;
// To execute C++, please define "int main()"
// The TestCase is shown below
// Input : 1 2
// Output : 3
/*
int main() {
int n;
cin>>n;
vector b(n);
vector result(n,0);
int maxLen = 0;
for(int i=0;i cin>>b[i];
int l = 0;
int r = maxLen;
while(l < r){
int mid = l + (r - l)/2;
if(result[mid] < b[i]){
l = mid + 1;
}else {
r = mid;
}
}
result[l] = b[i];
if(l == maxLen)maxLen++;
}
cout< return 0;
}
*/
int main(){
int n;
cin>>n;
vector b(n);
vector result(n,1);
int maxLen = 0;
for(int i=0;i cin>>b[i];
}
for(int i=1;i for(int j=0;j if(b[i] > b[j])result[i] = max(result[j] + 1,result[i]);
}
}
cout< return 0;
}
using namespace std;
// To execute C++, please define "int main()"
// The TestCase is shown below
// Input : 1 2
// Output : 3
/*
int main() {
int n;
cin>>n;
vector
vector
int maxLen = 0;
for(int i=0;i
int l = 0;
int r = maxLen;
while(l < r){
int mid = l + (r - l)/2;
if(result[mid] < b[i]){
l = mid + 1;
}else {
r = mid;
}
}
result[l] = b[i];
if(l == maxLen)maxLen++;
}
cout<
}
*/
int main(){
int n;
cin>>n;
vector
vector
int maxLen = 0;
for(int i=0;i
}
for(int i=1;i
}
}
cout<
}
全部评论
在赛马平台上都只能过10%,但是这两者方法我在lc上面都能过
注释里面是二分法,是我在面试时候写的,dp是我面试后写的都只能过10%
塞码真***
相关推荐