Algorithm · Google · Medium
You receive an integer array nums that should be treated as circular, meaning the position after the last element is the first element. For every index i, start just after i and move rightward, wrapping around the end of the array if necessary, and report the value of the earliest element that is strictly larger than nums[i]. If scanning the whole circle turns up no such element, report -1 for that index. Return an array with the same length as nums, where entry i holds the…