<qiyuangong>581_Shortest_Unsorted_Continuous_Subarray_3.py
def findUnsortedSubarray( nums):
    smin = 2 ** 31 -1
    smax = -2 ** 31
    flag = False
    for i in range(1, len(nums)):
        if nums[i] < nums[i-1]:
            flag = True
        if flag:
            smin = min(smin, nums[i])
    flag = False
    for i in range(len(nums)-2, -1, -1):
        if nums[i] > nums[i+1]:
            flag = True
        if flag:
            smax = max(smax, nums[i])
    for l in range(len(nums)):
        if smin < nums[l]:
            break
    for r in range(len(nums)-1, -1, -1):
        if smax > nums[r]:
            break
    if r > l:
        return r - l + 1
    return 0
def sample_funcname ( var_0 ) :
    var_4 = 2 ** 31 - 1
    var_5 = - 2 ** 31
    var_7 = False
    for var_10 in range ( 1 , len ( var_0 ) ) :
        if var_0 [ var_10 ] < var_0 [ var_10 - 1 ] :
            var_7 = True
        if var_7 :
            var_4 = min ( var_4 , var_0 [ var_10 ] )
    var_7 = False
    for var_10 in range ( len ( var_0 ) - 2 , - 1 , - 1 ) :
        if var_0 [ var_10 ] > var_0 [ var_10 + 1 ] :
            var_7 = True
        if var_7 :
            var_5 = max ( var_5 , var_0 [ var_10 ] )
    for var_14 in range ( len ( var_0 ) ) :
        if var_4 < var_0 [ var_14 ] :
            break
    for var_15 in range ( len ( var_0 ) - 1 , - 1 , - 1 ) :
        if var_5 > var_0 [ var_15 ] :
            break
    if var_15 > var_14 :
        return var_15 - var_14 + 1
    return 0
