5 4 5 2 10 8
For this input, the required output is 5 10 10 -1 -1.
5 10 10 -1 -1
5 5 4 3 2 1
For this input, the required output is -1 -1 -1 -1 -1.
-1 -1 -1 -1 -1
5 1 2 3 4 5
For this input, the required output is 2 3 4 5 -1.
2 3 4 5 -1
Given an array of nnn integers, for each element find the first greater element to its right.
If no greater element exists to the right, output −1-1−1 for that position.
nge1nge2⋯ngennge_1 \quad nge_2 \quad \cdots \quad nge_nnge1nge2⋯ngen