One More Easier 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    unordered_set<string> possiblePatterns(string s, int len) {\n        unordered_set<string> poss;\n        poss.insert(s);\n        \n        for(int i = 0; i < len; ++i) {\n            for(int j = i + 1; j < len; ++j) {\n                swap(s[i], s[j]);\n                poss.insert(s);\n                for(int a = 0; a < len; ++a) {\n                    for(int b = a+1; b < len; ++b) {\n                        if(s[a] != s[b]) {\n                            swap(s[a], s[b]);\n                            poss.insert(s);\n                            swap(s[b], s[a]);\n                        }\n                    }\n                }\n                swap(s[i], s[j]);\n            }\n        }\n        return poss;\n    }\npublic:\n    int countPairs(vector<int>& nums) {\n        int n = nums.size();\n        int maxLen = to_string(*max_element(nums.begin(),nums.end())).size();\n        auto makeDigit = [&](int num) {\n            string s = to_string(num);\n            int n = s.size();\n            for(int i=0;i<maxLen-n;i++)\n                s = "0" + s;\n            return s;\n        };\n        vector<string>numString;\n        for(auto&i : nums){\n            numString.push_back(makeDigit(i));\n        }\n        \n        unordered_map<string, int> mp;\n        int ans = 0;\n        for(int i = 0; i < n; ++i) {\n            for(const auto& s : possiblePatterns(numString[i], maxLen)) {\n                ans += mp[s];\n            }\n            mp[numString[i]]++;\n        }\n        return ans;\n    }\n};\n```
['C++']