Share my python code, run time 200+- 20ms
class Solution:\n        # @return a list of lists of length 4, [[val1,val2,val3,val4]]\n        def fourSum(self, num, target):\n            num.sort()\n      
    class Solution:\n        # @return a list of lists of length 4, [[val1,val2,val3,val4]]\n        def fourSum(self, num, target):\n            num.sort()\n            result = []\n            for i in xrange(len(num)-3):\n                if num[i] > target/4.0:\n                    break\n                if i > 0 and num[i] == num[i-1]:\n                    continue\n                target2 = target - num[i]\n                for j in xrange(i+1, len(num)-2):\n                    if num[j] > target2/3.0:\n                        break\n                    if j > i+1 and num[j] == num[j-1]:\n                        continue\n                    k = j + 1\n                    l = len(num) - 1\n                    target3 = target2 - num[j]\n                    # we should use continue not break\n                    # because target3 changes as j changes\n                    if num[k] > target3/2.0:\n                        continue\n                    if num[l] < target3/2.0:\n                        continue\n                    while k < l:\n                        sum_value = num[k] + num[l]\n                        if sum_value == target3:\n                            result.append([num[i], num[j], num[k], num[l]])\n                            kk = num[k]\n                            k += 1\n                            while k<l and num[k] == kk:\n                                k += 1\n                            \n                            ll = num[l]\n                            l -= 1\n                            while k<l and num[l] == ll:\n                                l -= 1\n                        elif sum_value < target3:\n                            k += 1\n                        else:\n                            l -= 1\n            return result\n\nWe can reduce run time by adding some restrictions.
['Python']