

A subsequence is a sequence that can be derived from another sequence by deleting zero or more elements without changing the order of the remaining elements.
The first line of input contains an integer ‘T’ denoting the number of test cases.
The first line of each test case contains an integer ‘N’ , the number of students in the row.
The second line of each test case contains ‘N’ space separated integers representing the height of every student in the row.
For each test case, return the length of longest strictly increasing subsequence of heights.
You do not need to print anything, it has already been taken care of. Just implement the given function.
1 <= T <= 10
1 <= N <= 200
1 <= heights[i] <=10^9
Time Limit: 1 sec
The idea is to find strictly increasing subsequences for all the elements of the array once including the elements in the sequence and once excluding it. In order to do this, we use a recursive function, 'LIS_HELPER' which returns the length of LIS possible from the current element (maximum of the lengths of subsequences once including the current element and once excluding it).
Algorithm:
LIS => Longest Increasing Subsequence.

Here, LIS(4) corresponds to LIS found up to index 4. LIS(4) will be calculated with the help of LIS(3), LIS(2), LIS(1).
Now, LIS(3) is calculated using the values of LIS(2) and LIS(1).
As you can see in the figure above this leads to recomputation of the same data again and again.
The idea is the same as the previous approach, but in the previous approach, many recursive calls were made again and again with the same parameters. This can be eliminated by storing the value obtained from a particular call in a 2d array, called the 'MEMO' array. 'MEMO'[i][j] stores the length of the LIS possible using 'HEIGHTS'[i] as the previous height(included / not included in LIS), and 'HEIGHTS'[j] as the current height(included / not included in LIS).
Algorithm:
This approach relies on the fact that the LIS possible upto ith index is independent of the elements coming after the ith index. Thus, for every index we will store the length of LIS possible upto that index in an array, say 'DP' array. For every index there will be two cases :
Algorithm: