-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path397.h
More file actions
31 lines (28 loc) · 814 Bytes
/
397.h
File metadata and controls
31 lines (28 loc) · 814 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
31
class Solution {
public:
/**
* @param A an array of Integer
* @return an integer
*/
int longestIncreasingContinuousSubsequence(vector<int>& A) {
// Write your code here
int length = A.size();
if(!length) return 0;
int L1[length] = {1};
for(int i = 1; i < length; ++i){
L1[i] = 1;
if(A[i] > A[i - 1])
L1[i] = L1[i - 1] + 1;
}
int L2[length];
L2[length - 1] = 1;
for(int i = length - 2; i >= 0; --i){
L2[i] = 1;
if(A[i] > A[i + 1])
L2[i] = L2[i + 1] + 1;
}
int max1 = *max_element(L1, L1 + length);
int max2 = *max_element(L2, L2 + length);
return max(max1, max2);
}
};