😂There's NO N*M^4 solution ,Passed N*M^5
Reason\n Describe your first thoughts on how to solve this problem. \nall of u will have ignored complexity of either comparing string or inserting numbers of s
# Reason\n<!-- Describe your first thoughts on how to solve this problem. -->\nall of u will have ignored complexity of either comparing string or inserting numbers of string into a set or interconversion, which is basically O(length of the string)\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:$$O(n*m^5)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:$$O(n+m^4)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```cpp []\n#include <bits/stdc++.h>\n\nusing namespace std;\n\nclass Solution {\npublic:\n\n    int countPairs(vector<int>& nums) {\n        int count = 0;\n        unordered_map<int,int>mp;\n        int maxLen=to_string(nums[0]).length();\n        mp[nums[0]]++;\n        for (int i = 1; i < nums.size(); ++i) {\n            string t=to_string(nums[i]);\n            int l=t.length();\n            maxLen=max(maxLen,l);\n            int len=maxLen-l;string s=t;\n            string c="";\n            for(int j=0;j<len;j++)c+="0";\n            s=c+s;\n            unordered_map<int,bool>seen;\n            for(int j=0;j<s.length();j++){\n                for(int k=j;k<s.length();k++){\n                    string t=s;\n                    swap(t[j],t[k]);\n                    for(int l=j;l<s.length();l++){\n                        for(int m=l;m<s.length();m++){\n                            string tt=t;\n                            swap(tt[l],tt[m]);\n                            int y=stoi(tt);\n                            if(seen.count(y))continue;\n                            count+=mp[y];\n                            seen[y]=true;\n                        }\n                    }\n                }\n            }\n            mp[nums[i]]++;\n        }\n        return count;\n    }\n\n};\n```
['C++']