TwoSum+twoSum == fourSum, a simple python solution
class Solution:\n    # @return a list of lists of length 4, [[val1,val2,val3,val4]]\n    def fourSum(self, num, target):\n        two_sum = collections.defaultd
    class Solution:\n    # @return a list of lists of length 4, [[val1,val2,val3,val4]]\n    def fourSum(self, num, target):\n        two_sum = collections.defaultdict(list)\n        res = set()\n        for (n1, i1), (n2, i2) in itertools.combinations(enumerate(num), 2):\n            two_sum[i1+i2].append({n1, n2})\n        for t in list(two_sum.keys()):\n            if not two_sum[target-t]:\n                continue\n            for pair1 in two_sum[t]:\n                for pair2 in two_sum[target-t]:\n                    if pair1.isdisjoint(pair2):\n                        res.add(tuple(sorted(num[i] for i in pair1 | pair2)))\n            del two_sum[t]\n        return [list(r) for r in res]
['Python']