Sneaker's Stub – The Grey Stuff!

The code below is Geeks for Geeks Sudo placement challenge for checking immediate smaller Element in an array and printing the desired output.

Geeks for Geeks challenge(Sudo Placement):

Given an integer array, for each element in the array check whether there exists a smaller element on the next immediate position of the array. If it exists print the smaller element. If there is no smaller element on the immediate next to the element then print -1.

Input:

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 an array.
The second line of each test case contains N integers separated with space which is input for the array arr[ ]

Output:

For each test case, print in a newline the next immediate smaller elements for each element in the array.