Clear and simple python3 solution with comment (O(n^3))
python\nclass Solution:\n    def fourSum(self, nums, target: int):\n        res = []\n        nums.sort()\n\n        # loop for first num, n times\n        for 
```python\nclass Solution:\n    def fourSum(self, nums, target: int):\n        res = []\n        nums.sort()\n\n        # loop for first num, n times\n        for i in range(len(nums) - 3):\n            \n            # skip duplication\n            if i > 0 and nums[i] == nums[i - 1]:\n                continue\n\n            # skip uneccesary case\n            if nums[i] * 4 > target:\n                break\n\n            # loop for second number, n times\n            for j in range(i + 1, len(nums) - 2):\n                \n                # skip duplication\n                if j > i + 1 and nums[j] == nums[j - 1]:\n                    continue\n\n                # skip uneccesary case\n                if nums[j] * 3 > target - nums[i]:\n                    break\n\n                # search for last 2 nums, same as 2Sum/3Sum problem\n                l, r = j + 1, len(nums) - 1\n\n                while l < r:\n                    \n                    s = nums[i] + nums[j] + nums[l] + nums[r]\n                    if s > target:\n                        r = r - 1\n                    elif s < target:\n                        l = l + 1\n                    else:\n                        res.append([nums[i], nums[j], nums[l], nums[r]])\n                        while l < r and nums[l] == nums[l + 1]:\n                            l = l + 1\n                        while l < r and nums[r] == nums[r - 1]:\n                            r = r - 1\n                        l, r = l + 1, r - 1\n            \n        return res\n\t\t```
['Python']