


If 'ARR' is [4,2,1,3] ,it can be splitted into two subsequences as [4,2,1] , [3] or [4,3],[2,1].
The first line of the input contains an integer, 'T’ , denoting the number of test cases.
The first line of each test case contains a single integer, 'N’, denoting the number of elements in ‘ARR’.
The next line of each test case has ‘N’ integers corresponding to the elements of 'ARR’.
For each test case, print a single integer corresponding to the minimum number of subsequences.
Output for each test case will be printed in a separate line.
You do not need to print anything. It has already been taken care of. Just implement the given function.
1 <= T <= 10
1 <= N <= 2000
1 <= 'ARR'[i] <= 10^6
Time limit: 1 sec
In this approach, we will prepare an array ‘USED ’ as USED[i] will state that whether any element can be inserted after ARR[i] or not. We will also maintain ‘ANS’ to store the number of subsequences. For each element, we will try also values left to that element and greedily pick the element whose value is just less than ARR[i]. If no such element is found, we will create a new subsequence and increase the value of ‘ANS’ by 1.
In this approach, we will prepare an array ‘SUBSEQUENCES’ to store the last element of each subsequence, and for each element, we will greedily pick the best subsequence using binary search over the ‘SUBSEQUENCES’ array. At last, we will return the size of the ‘SUBSEQUENCES’ array.