Given an array of positive integers A, find the first greater number for every element on its right. If a greater number does not exist, use -1.
Input: [1, 5, 2, 3, 5]
Output: [5, -1, 3, 5, -1]
The first line contains an integer âTâ, denoting the number of test cases.
For each test case the input has two lines:
For each test case, a line containing space-separated elements of the result.
4
5
1 5 2 3 5
4
1 2 3 4
5
3 2 1 4 5
4
4 3 2 1
5 -1 3 5 -1
2 3 4 -1
4 4 4 5 -1
-1 -1 -1 -1
1 <= T <= 100
1 <= n <= 104
1 <= Ai <= 105