Next Greater Element
For each element, print the first element to its right that is strictly greater, or -1. A monotonic stack solves it in .
Input
, then integers.
Output
answers.
Constraints
Sample 1
Input
4 4 5 2 25
Output
5 25 25 -1
Sample 2
Input
4 13 7 6 12
Output
-1 12 12 -1