https://www.interviewbit.com/problems/length-of-longest-subsequence/
Given an 1D integer array A of length N, find the length of longest subsequence which is first increasing then decreasing.
Problem Constraints 0 <= N <= 3000
-107 <= A[i] <= 107
Input Format The first and the only argument contains an integer array A.
Output Format Return an integer representing the answer as described in the problem statement.
Example Input Input 1:
A = [1, 2, 1] Input 2:
A = [1, 11, 2, 10, 4, 5, 2, 1]
Example Output Output 1:
3 Output 2:
6
Example Explanation Explanation 1:
[1, 2, 1] is the longest subsequence. Explanation 2:
[1 2 10 4 2 1] is the longest subsequence.