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 low<high:
b = nums[low]
c = nums[high]
if (a+b+c) == 0:
res.append([a,b,c])
while high>0 and (nums[high] == nums[high-1]):
high -=1
high-=1
while low<len(nums)-1 and nums[low] == nums[low+1]:
low +=1
low+=1
elif (a+b+c) > 0:
while high>0 and (nums[high] == nums[high-1]):
high -=1
high-=1
elif (a+b+c) < 0:
while low<len(nums)-1 and nums[low] == nums[low+1]:
low +=1
low+=1
print res