<doocs>0503.Next Greater Element II_1.py
def nextGreaterElements( nums: List[int]) -> List[int]:
    n = len(nums)
    ans = [-1] * n
    stk = []
    for i in range(n << 1):
        while stk and nums[stk[-1]] < nums[i % n]:
            ans[stk.pop()] = nums[i % n]
        stk.append(i % n)
    return ans
def sample_funcname ( var_0 : List [ int ] ) -> List [ int ] :
    var_4 = len ( var_0 )
    var_6 = [ - 1 ] * var_4
    var_7 = [ ]
    for var_9 in range ( var_4 << 1 ) :
        while var_7 and var_0 [ var_7 [ - 1 ] ] < var_0 [ var_9 % var_4 ] :
            var_6 [ var_7.pop ( ) ] = var_0 [ var_9 % var_4 ]
        var_7.append ( var_9 % var_4 )
    return var_6
