Easy Brute force Solution | | 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 {\n    string makeDigit(int num, int digits) {\n        string s = to_string(num);\n        int n = s.size();\n        for(int i=0;i<digits-n;i++)\n            s = "0" + s;\n        return s;\n    }\n\n    unordered_set<string> makeSwapChanges(int num, int digits) {\n        string s = makeDigit(num, digits);\n        unordered_set<string> poss;\n        poss.insert(s);\n        \n        for(int i = 0; i < digits; ++i) {\n            for(int j = i + 1; j < digits; ++j) {\n                swap(s[i], s[j]);\n                poss.insert(s);\n                for(int i1 = 0; i1 < digits; ++i1) {\n                    for(int j1 = i1+1; j1 < digits; ++j1) {\n                        if(s[i1] != s[j1]) {\n                            swap(s[i1], s[j1]);\n                            poss.insert(s);\n                            swap(s[j1], s[i1]);\n                        }\n                    }\n                }\n                swap(s[i], s[j]);\n            }\n        }\n        return poss;\n    }\n\npublic:\n    int countPairs(vector<int>& nums) {\n        int n = nums.size();\n        int digits = to_string(*max_element(nums.begin(),nums.end())).size();\n\n        unordered_map<string, int> mp;\n        int ans = 0;\n        for(int i = 0; i < n; ++i) {\n            for(const auto& s : makeSwapChanges(nums[i], digits)) {\n                if(mp.count(s)) {\n                    ans += mp[s];\n                }\n            }\n            mp[makeDigit(nums[i], digits)]++;\n        }\n\n        return ans;\n    }\n};\n```
['C++']