


Given ‘N’ = 4 and ‘ARR’[] = 1, 2, 3, 4.
The answer will be ‘1’ because an increasing subsequence of [1, 2, 3, 4] having length greater than 3 can be made.
The first line of input contains an integer ‘T’ denoting the number of test cases.
The first line of each test case contains a single integer 'N', where ‘N’ is the number of elements of the array/list 'ARR'.
The second line of each test case contains ‘N’ single space-separated integers, denoting the 'ARR' elements.
For each test case, print a single line containing '1' if you can split 'ARR' into one or more subsequences such that each subsequence consists of consecutive integers and has a length of at least 3. Else, print '0'.
The output of 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 <= 5
1 <= N <= 5000
-1250 <= ARR[ i ] <= 1250
Where ‘T’ is the total number of test cases, and 'N’ is the length of 'ARR' and ‘ARR[i]’ is the array element at index ‘i’.
Time limit: 1 second
The main idea is to maintain two hash-maps ‘frqMap’ and ‘seqMap’, which keep track of the frequency of each element in the array, and the following number that the sequence formed may need, respectively.
The main idea is to check the subsequence of length 1 and length 2 and if they are the only subsequences that can be formed for a given number then return ‘false’ else return true.