求一数组中元素相加为0的三元组

nums = [0, -1, 2, -3, 1]
nums = sorted(nums)
res = []
for i in range(len(nums)):
    low = i+1
    high = len(nums)-1
    a = nums[i]

    while low0 and (nums[high] == nums[high-1]):
                 high -=1
             high-=1
             while low 0:
             while high>0 and (nums[high] == nums[high-1]):
                 high -=1
             high-=1
         elif (a+b+c) < 0:
             while low

 

你可能感兴趣的:(求一数组中元素相加为0的三元组)