💥 C# | Runtime and memory beats 95.29%
Intuition\nI have to find all unique sets of four numbers that sum up to a given target. To do this efficiently, I need to avoid checking the same set multiple 
# Intuition\nI have to find all unique sets of four numbers that sum up to a given target. To do this efficiently, I need to avoid checking the same set multiple times and handle duplicates properly.\n\n# Approach\nSort the Array: Helps in managing duplicates and using the two-pointer technique.\n\nFix Two Numbers: Use two nested loops to choose the first two numbers.\n\nTwo-pointer Technique: Use pointers to find the other two numbers that make the target sum.\n\nSkip Duplicates: Ensure unique quadruplets by skipping duplicate values.\n\n# Complexity\n- Time complexity:\nO(n3) due to sorting and nested loops.\n\n- Space complexity:\nO(1) extra space (excluding result storage).\n\n# Code\n```csharp []\npublic class Solution\n{\n    public IList<IList<int>> FourSum(int[] nums, int target)\n    {\n        Array.Sort(nums);\n        var result = new List<IList<int>>();\n        int n = nums.Length;\n\n        for (int i = 0; i < n - 3; i++)\n        {\n            if (i > 0 && nums[i] == nums[i - 1]) continue; // Skip duplicates for i\n\n            for (int j = i + 1; j < n - 2; j++)\n            {\n                if (j > i + 1 && nums[j] == nums[j - 1]) continue; // Skip duplicates for j\n\n                int left = j + 1;\n                int right = n - 1;\n                long targetSum = (long)target - nums[i] - nums[j]; // Use long to avoid overflow\n\n                while (left < right)\n                {\n                    long sum = (long)nums[left] + nums[right]; // Use long to avoid overflow\n                    if (sum == targetSum)\n                    {\n                        result.Add(new List<int> { nums[i], nums[j], nums[left], nums[right] });\n                        while (left < right && nums[left] == nums[left + 1]) left++; // Skip duplicates for left\n                        while (left < right && nums[right] == nums[right - 1]) right--; // Skip duplicates for right\n                        left++;\n                        right--;\n                    }\n                    else if (sum < targetSum) left++;\n                    else right--;\n                }\n            }\n        }\n\n        return result;\n    }\n}\n\n```
['C#']