|All-time Popular Problems|
|Inorder Successor in BST|
|Maximum Product Subarray|
|Is Binary Number Multiple of 3|
|Pairwise swap elements of a linked list by swapping data|
|Largest Number formed from an Array|
|Reverse an Array|
|Boundary Traversal of binary tree|
|Leaders in an array|
Given an array arr[0..n-1] of positive element. The task is to print remaining elements of arr after repeated deletion of LIS (of size greater than 1). If there are multiple LIS with same length, we need to choose the LIS that ends first.
The first line of input contains an integer T denoting the number of test cases. Then T test cases follow. The first line of each test case contains an integer N denoting the size of array A.
The second line of each test case contains N space separated integers denoting elements of the array A[ ].
Print the elements of the array which remain after repeated deletion of the LIS for each test case in a new line. If the array is empty print -1.
1<= T <=100
1<= N <=500
1<= A[ ] <=1000
1 2 5 3 6 4 1
1 2 3 1 5 2