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


  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.



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




** 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, generate link and share the link here.

to report an issue on this page.