<doocs>0962.Maximum Width Ramp_1.py
def maxWidthRamp( nums: List[int]) -> int:
    stk = []
    for i, v in enumerate(nums):
        if not stk or nums[stk[-1]] > v:
            stk.append(i)
    ans = 0
    for i in range(len(nums) - 1, -1, -1):
        while stk and nums[stk[-1]] <= nums[i]:
            ans = max(ans, i - stk.pop())
        if not stk:
            break
    return ans
def sample_funcname ( var_0 : List [ int ] ) -> int :
    var_3 = [ ]
    for var_5 , var_6 in enumerate ( var_0 ) :
        if not var_3 or var_0 [ var_3 [ - 1 ] ] > var_6 :
            var_3.append ( var_5 )
    var_10 = 0
    for var_5 in range ( len ( var_0 ) - 1 , - 1 , - 1 ) :
        while var_3 and var_0 [ var_3 [ - 1 ] ] <= var_0 [ var_5 ] :
            var_10 = max ( var_10 , var_5 - var_3.pop ( ) )
        if not var_3 :
            break
    return var_10
