✔️ 100% Fastest Swift Solution
\nclass Solution {\n    func fourSum(_ nums: [Int], _ target: Int) -> [[Int]] {\n        let sorted = nums.sorted()\n        var res: [[Int]] = []\n        var 
```\nclass Solution {\n    func fourSum(_ nums: [Int], _ target: Int) -> [[Int]] {\n        let sorted = nums.sorted()\n        var res: [[Int]] = []\n        var i = 0\n        \n        while i < sorted.count - 3 {\n            if i > 0, sorted[i] == sorted[i - 1] { i += 1; continue }\n            var j = i + 1\n            while j < sorted.count - 2 {\n                if j - 1 > i, sorted[j] == sorted[j - 1] { j += 1; continue }\n                var k = j + 1\n                var l = sorted.count - 1\n                \n                while k < l {\n                    let sum = sorted[i] + sorted[j] + sorted[k] + sorted[l]\n                    if sum == target {\n                        if k - 1 > j, sorted[k] == sorted[k - 1] { k += 1; continue }\n                        res.append([sorted[i], sorted[j], sorted[k], sorted[l]])\n                        k += 1\n                    }\n                    if sum < target {\n                        k += 1\n                    } else {\n                        l -= 1\n                    }\n                }\n                j += 1\n            }\n            i += 1\n        }\n\n        return res\n    }\n\n}\n```\n\nLet me know in comments if you have any doubts. I will be happy to answer.\n\nPlease upvote if you found the solution useful.
['Swift']