Hard
Next Bigger Number to the Right
Read integers. For each one, print the first number to its right that is bigger, or -1 if there is none. Use a list as a stack of positions still waiting for an answer.
Input
Integers separated by spaces.
Output
One line.
Sample 1
Input
4 5 2 25
Output
5 25 25 -1
Sample 2
Input
13 7 6 12
Output
-1 12 12 -1
Output appears here