Size of array after repeated deletion of LIS
Submissions: 562   Accuracy:

13.29%

  Difficulty: Easy   Marks: 2

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
Author: sujnesh


If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.



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


to report an issue on this page.