The list is circular: after the last element comes the first one again. For each value, find the next strictly greater value, looking to the right and wrapping around the end if needed; return -1 if there is none.
For [1, 2, 1] the answer is [2, -1, 2].
Example 1
Input:
next_greater_circular([1, 2, 1])
Output:
[2, -1, 2]
Example 2
Input:
next_greater_circular([1, 2, 3, 4, 3])
Output:
[2, 3, 4, -1, 4]
0 <= len(nums) <= 200000-10**9 <= nums[i] <= 10**9No results yet
Run your code to check it against the examples, or submit to run every test.