-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlic.cpp
42 lines (36 loc) · 819 Bytes
/
lic.cpp
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
31
32
33
34
35
36
37
38
39
40
41
42
#include <iostream>
#include <vector>
using namespace std;
void prt(vector<int>& arr, string msg = "") {
cout << msg << " ";
for (auto i: arr) {
cout << i << " ";
}
cout << endl;
}
void LongestSubsection(vector<int>& D) {
vector< vector<int> > L(D.size());
L[0].push_back(D[0]);
for (int i=1; i<D.size(); i++) {
for(int j=0; j<i; j++) {
if ( (D[j] < D[i]) && ( L[i].size() < L[j].size() ) ) {
L[i] = L[j];
}
}
L[i].push_back(D[i]);
}
for (auto x: L) {
prt(x);
}
}
int main() {
int a[] = {12, 2, 10, 6, 14, 1, 9, 5, 13, 3, 11, 7, 15,100,2323};
vector<int> arr(a, a + sizeof(a)/sizeof(a[0]));
//prt(arr, "Data In:");
for(int i=0;i<arr.size();i++){
cout<<arr[i]<<" ";
}
cout<<endl;
LongestSubsection(arr);
return 0;
}