-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprogram.cpp
More file actions
30 lines (28 loc) · 721 Bytes
/
program.cpp
File metadata and controls
30 lines (28 loc) · 721 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include "../include/pre.h"
int lengthOfLIS(vector<int>& nums)
{
if (nums.size() == 0) return 0;
vector<int> minEnd;
minEnd.push_back(nums[0]);
cout << minEnd << endl;
for (int i = 1; i < nums.size(); i++)
{
auto upper = std::lower_bound(minEnd.begin(), minEnd.end(), nums[i]);
if (upper == minEnd.end()) {
minEnd.push_back(nums[i]);
}
else {
*upper = nums[i];
}
cout << minEnd << endl;
}
return minEnd.size();
}
int main()
{
//vector<int> test = {10,9,2,5,3,7,101,18};
vector<int> test = {3,5,6,2,5,4,19,5,6,7,12};
//vector<int> test = {2, 2};
cout << lengthOfLIS(test) << endl;
return 0;
}