Simple brute force, C++
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```cpp []\nclass Solution {\npublic:\n    int countPairs(vector<int>& nums) {\n        sort(nums.begin(), nums.end());\n        unordered_map<int, int> cnt;\n        int res = 0;\n        for (int num : nums){\n            string s = to_string(num);\n            int n = s.size();\n            set<int> Set;\n            Set.insert(num);\n            for (int i = 0; i < n; i++){\n                for (int j = i + 1; j < n; j++){\n                    string s2 = s;\n                    swap(s2[i], s2[j]);\n                    Set.insert(stoi(s2));\n                    for (int k = 0; k < n; k++){\n                        for (int l = k + 1; l < n; l++){\n                            string s3 = s2;\n                            swap(s3[k], s3[l]);\n                            Set.insert(stoi(s3));\n                        }\n                    }\n                }\n            }\n            for (int i : Set)\n                res += cnt[i];\n\n            cnt[num]++;\n        }\n        return res;\n    }\n};\n```
['C++']