values are arranged in a circle: the first element comes right after the last one.
For each element, find the first number strictly larger than it when you move forward around the circle from that element. If there is none, use -1.
Return the answers as an array of the same length, in the same order as values.values=[4, 9, 2, 6] → [9, -1, 6, 9]
The 4 is followed right away by 9. Nothing beats 9, so it gets -1. The 2 is followed by 6. After 6 the circle goes on to 4 and then 9, so its answer is 9.
values=[7, 7, 3] → [-1, -1, 7]
An equal value does not count as larger, so both 7s get -1. For the 3, the circle continues to a 7.
values=[-5] → [-1]
values=[4, 9, 2, 6]
[9, -1, 6, 9]
Run checks the first 3 tests in your browser. Submit checks all 125 tests on the server, hidden ones included.