BETA

Difficulty Level: Easy

Submissions: 118 Accuracy:

10.17%

Size of array after repeated deletion of LIS
     

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.

 

Input:

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[ ].

 

Output:

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.


Constraints:

1<= T <=100

1<= N <=500

1<= A[ ] <=1000


Example:

Input:

2

7

1 2 5 3 6 4 1

6

1 2 3 1 5 2

Output:

1

-1

** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Sujnesh Mishra

Set Default Code

					   
It is recommended to 'Compile & Test' your code before clicking 'Submit'!

Compilation/Execution Result:

Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.