For each element in the array, find the next greater element using a stack.
Input Format
Integer n n space-separated integers
Output Format
n space-separated integers (next greater or -1)
Sample Input
4 4 5 2 10
Sample Output
5 10 10 -1
For each element in the array, find the next greater element using a stack.
Integer n n space-separated integers
n space-separated integers (next greater or -1)
4 4 5 2 10
5 10 10 -1