Problem Description
Given a 1D integer array A of length N, find the length of the longest subsequence which is first increasing (strictly) and then decreasing (strictly).
0 <= N <= 3000
-107 <= A[i] <= 107
The first and the only argument contains an integer array A.
Return an integer representing the answer as described in the problem statement.
Input 1:
A = [1, 2, 1]
Input 2:
A = [1, 11, 2, 10, 4, 5, 2, 1]
Output 1:
3
Output 2:
6
Explanation 1:
[1, 2, 1] is the longest subsequence.
Explanation 2:
[1 2 10 4 2 1] is the longest subsequence.
NOTE: You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a question? Checkout Sample Codes for more details.