```
class Solution(object):
def threeSum(self, nums):
res = []
for i,n in enumerate(nums):
two = self.twoSum(nums[i + 1:], 0 - n)
if two:
three = [ sorted(x + [n]) for x in two ]
for t in three:
if t not in res:
res += t,
return res
def twoSum(self, nums, target):
got = {}
res = []
for n in nums:
if n not in got:
got[target - n] = n
else:
res += [got[n], n],
return res
```