Brute Force || O(N*7*7*7*7)
Intuition\n Describe your first thoughts on how to solve this problem. \nFor each number take a hashmap of all the values that can be formed by applying either 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nFor each number take a hashmap of all the values that can be formed by applying either one or two operations. Then simaltaneously check all that values whether have occured in the nums till now if yes add their freq to your main ans. \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    O(N*(7^4))\n    N for iteration and 4 loops on max digit size of 7 and extraction complexity of unordered_map O(1).\n\n# Code\n```cpp []\nclass Solution {\npublic:\n    unordered_map<string,int>dp;\n    string makeDigit(int num, int digits) {//func for digitmakeup\n        string s = to_string(num);\n        int n = s.size();\n        for(int i=0;i<digits-n;i++)\n            s = "0" + s;\n        return s;\n    }\n    unordered_map<string,int>getnums(int num,int digits_makeup){\n        string s = makeDigit(num,digits_makeup);\n        unordered_map<string,int>mp;\n        mp[s]++;\n        for(int i = 0; i < s.length(); i++){\n            for(int j = i + 1; j < s.length(); j++){\n                swap(s[i],s[j]);\n                mp[s]++;\n                for(int k = 0; k < s.length(); k++){\n                    for(int l = k + 1; l < s.length(); l++){\n                        if(s[k]!=s[l]){\n                            swap(s[k],s[l]);\n                            mp[s]++;\n                            swap(s[k],s[l]);\n                        }\n                    }\n                }\n                swap(s[i],s[j]);\n            }\n        }\n        return mp;\n    }\n    int countPairs(vector<int>& nums) {\n        // O(N*49*49) here\n        int n=nums.size();\n        int digits_makeup = to_string(*max_element(nums.begin(),nums.end())).size();\n        int ans=0;\n        for(int i=0;i<nums.size();i++){\n            for(auto s:getnums(nums[i],digits_makeup)){\n                if(dp.count(s.first)){\n                    ans+=dp[s.first];\n                }\n            }\n            dp[makeDigit(nums[i],digits_makeup)]++;\n        }\n        return ans;\n    }\n};\n```
['C++']