Brute Force Using Map
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 []\n#define ll long long\nclass Solution {\npublic:\n    unordered_set<string> f(string& s, ll n){\n        unordered_set<string> st;\n        st.insert(s);\n        for(ll i=0; i<n; i++){\n            for(ll j=i+1; j<n; j++){\n                if(s[i]!=s[j]){\n                    swap(s[i], s[j]);\n                    st.insert(s);\n                    for(ll i1=0; i1<n; i1++){\n                        for(ll i2=i1+1; i2<n; i2++){\n                            if(i!=i1 and j!=i2){\n                                swap(s[i1], s[i2]);\n                                st.insert(s);\n                                swap(s[i1], s[i2]);\n                            }\n                        }\n                    }\n                    swap(s[i], s[j]);\n                }\n            }\n        }\n        return st;\n    }\n    int countPairs(vector<int>& nums) {\n        vector<string> v;\n        ll n=nums.size();\n        ll ans=0;\n        for(ll i=0; i<n; i++){\n            string str=to_string(nums[i]);\n            while(str.length()<7) str=\'0\'+str;\n            v.push_back(str);\n        }\n        unordered_map<string, ll> mp;\n        mp[v[0]]++;\n        for(ll i=1; i<n; i++){\n            unordered_set<string> st=f(v[i], 7);\n            for(auto e: st){\n                if(mp.count(e)) ans+=mp[e];\n            }\n            mp[v[i]]++;\n        }\n        return ans;\n    }\n};\n```
['C++']