Easy Solution :)
Code\ncpp []\nclass Solution {\npublic:\n    int countPairs(vector<int>& nums) {\n        int n = nums.size();\n        int count = 0;\n        unordered_map<in
# Code\n```cpp []\nclass Solution {\npublic:\n    int countPairs(vector<int>& nums) {\n        int n = nums.size();\n        int count = 0;\n        unordered_map<int,int>mp;\n        for(auto&it:nums)mp[it]++; \n        vector<vector<int>> pos(n);\n        for (int i = 0; i < n; ++i) {\n            pos[i] = f(nums[i]); \n        } \n        for (int i = 0; i < n; ++i) {\n            mp[nums[i]]--;\n            if(mp[nums[i]]==0)mp.erase(nums[i]);\n            for (int j = 0; j < pos[i].size(); ++j) {\n                 if(mp.find(pos[i][j])!=mp.end())count+=mp[pos[i][j]];\n            } \n        }\n        return count;\n    }\n    private:\n    vector<int> f(int num) {\n            unordered_set<int>rev;\n            string s = to_string(num);\n            reverse(s.begin(),s.end());\n            for(int i=s.size();i<7;i++)s.push_back(\'0\');\n            reverse(s.begin(),s.end());\n            int len = s.length();\n            rev.insert(num);\n            for (int i = 0; i < len; ++i) {\n                for (int j = i + 1; j < len; ++j) {\n                    swap(s[i], s[j]);\n                    int num = stoi(s); \n                    for (int ii = 0; ii < len; ++ii) {\n                        for (int jj = ii + 1; jj < len; ++jj) {\n                            swap(s[ii], s[jj]);\n                            int num = stoi(s);\n                            rev.insert(num);\n                            swap(s[ii], s[jj]);\n                        }\n                    } \n                    rev.insert(num);\n                    swap(s[i], s[j]);\n                }\n            } \n            vector<int>v;\n            for(auto&it:rev)v.push_back(it);\n            return v;\n        };\n}; \n```
['C++']