My 16ms c++ code
class Solution {\n    public:\n        vector<vector<int>> fourSum(vector<int>& nums, int target) {\n            vector<vector<int>> total;\n            int n =
    class Solution {\n    public:\n        vector<vector<int>> fourSum(vector<int>& nums, int target) {\n            vector<vector<int>> total;\n            int n = nums.size();\n            if(n<4)  return total;\n            sort(nums.begin(),nums.end());\n            for(int i=0;i<n-3;i++)\n            {\n                if(i>0&&nums[i]==nums[i-1]) continue;\n                if(nums[i]+nums[i+1]+nums[i+2]+nums[i+3]>target) break;\n                if(nums[i]+nums[n-3]+nums[n-2]+nums[n-1]<target) continue;\n                for(int j=i+1;j<n-2;j++)\n                {\n                    if(j>i+1&&nums[j]==nums[j-1]) continue;\n                    if(nums[i]+nums[j]+nums[j+1]+nums[j+2]>target) break;\n                    if(nums[i]+nums[j]+nums[n-2]+nums[n-1]<target) continue;\n                    int left=j+1,right=n-1;\n                    while(left<right){\n                        int sum=nums[left]+nums[right]+nums[i]+nums[j];\n                        if(sum<target) left++;\n                        else if(sum>target) right--;\n                        else{\n                            total.push_back(vector<int>{nums[i],nums[j],nums[left],nums[right]});\n                            do{left++;}while(nums[left]==nums[left-1]&&left<right);\n                            do{right--;}while(nums[right]==nums[right+1]&&left<right);\n                        }\n                    }\n                }\n            }\n            return total;\n        }\n    };
['C++']