Back to DSA
Next Greater Element II
mediumGiven a circular integer array, determine the next strictly greater element for each position. Because the array wraps around, an element's next-greater value may appear before it in the array. Return -1 for any position where no greater element exists in the full circle.
Examples
Example 1:
Input:
nums = [3,1,4]Output:
[4,-1,-1] Example 2:
Input:
nums = [5,4,3,2,6]Output:
[6,6,6,6,-1]Hints
1234567