O(n^2) method with cpp
It is very tricky that for cpp user, it would not be that much easier to implement the O(n^2) method since the deduplicate process is a bit disgusting. Here, I 
It is very tricky that for cpp user, it would not be that much easier to implement the O(n^2) method since the deduplicate process is a bit disgusting. Here, I would share my code that solve such problem with built-in unique() function so as to implement the O(n^2) method. If you have any better method, please tell me. \n```\nclass Solution {\npublic:\n    vector<vector<int>> fourSum(vector<int>& nums, int target) {\n        vector<vector<int>> result;\n        if (nums.size() == 0)\n            return result;\n        \n        unordered_map<int, vector<pair<int, int>>> map;\n        for (int i = 0; i < nums.size(); ++i) {\n            for (int j = i + 1; j < nums.size(); ++j) {\n                map[target - nums[i] - nums[j]].push_back({i, j});\n            }\n        }\n        \n        for (int i = 0; i < nums.size(); ++i) {\n            for (int j = i + 1; j < nums.size(); ++j) {\n                int temp = nums[i] + nums[j];\n                if (map.find(temp) != map.end()) {\n                    for (auto p : map[temp]) {\n                        if (p.first == i || p.first == j ||\n                            p.second == i || p.second == j)\n                            continue;                        \n                        result.push_back({nums[p.first], nums[p.second], nums[i], nums[j]});\n                        \n                    }\n                }\n            }\n        }\n        \n        for (int i = 0; i < result.size(); ++i) {\n            sort(result[i].begin(), result[i].end());\n        }\n        sort(result.begin(), result.end());\n        result.erase(unique(result.begin(), result.end()), result.end());\n        \n        return result;\n    }\n};\n```
[]