<doocs>0018.4Sum_1.py
def fourSum( nums: List[int], target: int) -> List[List[int]]:
    n, res = len(nums), []
    if n < 4:
        return []
    nums.sort()
    for i in range(n - 3):
        if i > 0 and nums[i] == nums[i - 1]:
            continue
        for j in range(i + 1, n - 2):
            if j > i + 1 and nums[j] == nums[j - 1]:
                continue
            k, l = j + 1, n - 1
            while k < l:
                if nums[i] + nums[j] + nums[k] + nums[l] == target:
                    res.append([nums[i], nums[j], nums[k], nums[l]])
                    k += 1
                    l -= 1
                    while k < n and nums[k] == nums[k - 1]:
                        k += 1
                    while l > j and nums[l] == nums[l + 1]:
                        l -= 1
                elif nums[i] + nums[j] + nums[k] + nums[l] < target:
                    k += 1
                else:
                    l -= 1
    return res
def sample_funcname ( var_0 : List [ int ] , var_3 : int ) -> List [ List [ int ] ] :
    var_5 , var_6 = len ( var_0 ) , [ ]
    if var_5 < 4 :
        return [ ]
    var_0.sort ( )
    for var_11 in range ( var_5 - 3 ) :
        if var_11 > 0 and var_0 [ var_11 ] == var_0 [ var_11 - 1 ] :
            continue
        for var_15 in range ( var_11 + 1 , var_5 - 2 ) :
            if var_15 > var_11 + 1 and var_0 [ var_15 ] == var_0 [ var_15 - 1 ] :
                continue
            var_16 , var_17 = var_15 + 1 , var_5 - 1
            while var_16 < var_17 :
                if var_0 [ var_11 ] + var_0 [ var_15 ] + var_0 [ var_16 ] + var_0 [ var_17 ] == var_3 :
                    var_6.append ( [ var_0 [ var_11 ] , var_0 [ var_15 ] , var_0 [ var_16 ] , var_0 [ var_17 ] ] )
                    var_16 += 1
                    var_17 -= 1
                    while var_16 < var_5 and var_0 [ var_16 ] == var_0 [ var_16 - 1 ] :
                        var_16 += 1
                    while var_17 > var_15 and var_0 [ var_17 ] == var_0 [ var_17 + 1 ] :
                        var_17 -= 1
                elif var_0 [ var_11 ] + var_0 [ var_15 ] + var_0 [ var_16 ] + var_0 [ var_17 ] < var_3 :
                    var_16 += 1
                else :
                    var_17 -= 1
    return var_6
