Given an array of N distinct elements, the task is to find all elements in array except two greatest elements.
The first line of input contains an integer T denoting the number of test cases. Each test case contains two lines. The first line of input contains an integer N denoting the size of the array. Then in the next line are N space separated array elements.
For each test case in a new line print the space separated sorted values denoting the elements in array which have at-least two greater elements than themselves.
2 8 7 1 5
7 -2 3 4 9 -1
1 2 5
-2 -1 3 4
Testcase 1: Largest two elements are 7 and 8. So array left is 1 2 5.
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.