Given a circular integer array nums (i.e., the next element of nums[nums.length - 1] is nums[0]), return the next greater number for every element in nums.
The next greater number of a number x is the first greater number to its traversing-order next in the array, which means you could search circularly to find its next greater number. If it doesn't exist, return -1 for this number.
Examples
Example 1
Input: nums = [1, 2, 1]
Output: [2, -1, 2]
The next greater number for 1 is 2. The number 2 has no greater number. The next greater of the last 1 is 2 (wrapping around).
Example 2
Input: nums = [1, 2, 3, 4, 3]
Output: [2, 3, 4, -1, 4]
Example 3
Input: nums = [5, 4, 3, 2, 1]
Output: [-1, 5, 5, 5, 5]
Every element except 5 wraps around and finds 5 as the next greater.
Constraints
1 <= nums.length <= 10000-10^9 <= nums[i] <= 10^9