|All-time Popular Problems|
|Sort a stack|
|Delete Middle of Linked List|
|BFS traversal of graph|
|Largest subarray of 0's and 1's|
|Immediate Smaller Element|
|Delete nodes having greater value on right|
|Node at a given index in linked list|
|Two numbers with sum closest to zero|
|Print all nodes that don’t have sibling|
Given an integer array, for each element in the array check whether there exist a smaller element on the next immediate position of the array. If it exist print the smaller element. If there is no smaller element on the immediate next to the element then print -1.
The first line of input contains an integer T denoting the number of test cases.
The first line of each test case contains an integer N, where N is the size of array.
The second line of each test case contains N integers sperated with a space which is input for the array arr[ ]
For each test case, print in a newline the next immediate smaller elements for each element in the array.
1 ≤ T ≤ 100
1 ≤ N ≤ 500
1 ≤ arr[i] ≤ 1000
4 2 1 5 3
5 6 2 3 1 7
2 1 -1 3 -1
-1 2 -1 1 -1 -1