ONLY SUGGESTION : This problem has a very tight time constraint!!
Intuition\n Describe your first thoughts on how to solve this problem. \nFor each element calculate all the elements that could be created using two swaps of di
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nFor each element calculate all the elements that could be created using two swaps of digits. Rest of the comments in the code. \n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nPlease check the comments. \n\n# Complexity\n- Time complexity:\n- (n * 2043)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n- \n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```cpp []\nclass Solution {\npublic:\n    unordered_map<int, bool>mp;\n    string adjust(string s) {\n        string a = s;\n        reverse(a.begin(), a.end());\n        for(int i = 0; i < 7 - s.size(); i++) {\n            a.push_back(\'0\');\n        }\n        reverse(a.begin(), a.end());\n        return a;\n    }\n    // void add(int x) {\n    //     // adjust(x);\n    //     string a = to_string(x);\n    //     a = adjust(a);\n    //     for(int i = 0; i < a.size(); i++) {\n    //         for(int j = i + 1; j < a.size(); j++) {\n    //             swap(a[i], a[j]);\n    //             mp[x][stoi(a)] = true;\n    //             for(int l = 0; l < a.size(); l++) {\n    //                 for(int m = l + 1; m < a.size(); m++) {\n    //                     swap(a[l], a[m]);\n    //                     mp[x][stoi(a)] = true;\n    //                     swap(a[l], a[m]);\n    //                 }\n    //             }\n    //             swap(a[i], a[j]);\n    //         }\n    //     }\n    // }\n    int countPairs(vector<int>& nums) {\n        mp.clear();\n        // for(auto x : nums) {\n        //     add(x);\n        // }\n        long long ans = 0;\n        unordered_map<int, int>mp1;\n        \n        \n        for(int i = 0; i < nums.size(); i++) {\n\n            {\n                int x = nums[i];\n                mp.clear();\n                string a = to_string(x);\n                a = adjust(a);\n                for(int i = 0; i < a.size(); i++) {\n                    for(int j = i + 1; j < a.size(); j++) {\n                        swap(a[i], a[j]);\n                        mp[stoi(a)] = true;\n                        for(int l = 0; l < a.size(); l++) {\n                            for(int m = l + 1; m < a.size(); m++) {\n                                swap(a[l], a[m]);\n                                mp[stoi(a)] = true;\n                                swap(a[l], a[m]);\n                            }\n                        }\n                        swap(a[i], a[j]);\n                    }\n                }\n            }\n\n\n\n            for(auto x : mp) {\n                ans += mp1[x.first];\n            }\n            mp1[nums[i]]++;\n        }\n        // for(auto x : nums) {\n        //     ans += (mp1[x] - 1);\n        // }\n        // ans /= 2;\n        return ans;\n    }\n};\n```
['C++']