Easy C++ Code with Comments for better understanding.
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: O(n^2)\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 []\nclass Solution {\npublic:\n    // Function to make num containing count of digits as \'digits\'.\n    string makeEqual(int num, int digits) {\n        string t = to_string(num);\n        // If a string has smaller size then adding leading 0 to make it the same size as others.\n        while (t.size() < digits) {\n            t = "0" + t;\n        }\n        return t;\n    }\n\n    // Making all possible swaps for number num.\n    // TC: O(7^4) as digits in num at most 7 and two swaps will be performed using 7^4 which is constant and small.\n    unordered_set<string> makeSwap(int num, int digits) {\n        // First making it of the same size as others.\n        string t = makeEqual(num, digits);\n        unordered_set<string> st;\n        st.insert(t);\n        // Performing all possible swaps.\n        for (int i = 0; i < t.size(); i++) {\n            for (int j = i + 1; j < t.size(); j++) {\n                swap(t[i], t[j]);\n                // Inserting the first swapped string into the set.\n                st.insert(t);\n                // Second swap on the first swapped string.\n                for (int i1 = 0; i1 < t.size(); i1++) {\n                    for (int j1 = i1 + 1; j1 < t.size(); j1++) {\n                        swap(t[i1], t[j1]);\n                        // Inserting into the set.\n                        st.insert(t);\n                        // Reverting the second swap to the previous string so that another swap can be performed.\n                        swap(t[i1], t[j1]);\n                    }\n                }\n                // Reverting the first swap.\n                swap(t[i], t[j]);\n            }\n        }\n        return st;\n    }\n\n    int countPairs(vector<int>& nums) {\n        int n = nums.size();\n        int ans = 0;\n        int maxi = 0;\n        \n        // Find the maximum number of digits in the numbers.\n        for (auto it : nums) {\n            string t = to_string(it);\n            maxi = max(maxi, (int)t.size());\n        }\n        \n        unordered_map<int, int> mp;\n        for (int i = 0; i < n; i++) {\n            // After making all possible swaps for nums[i].\n            for (auto &it : makeSwap(nums[i], maxi)) {\n                int val = stol(it);\n                // Checking if any number is present in the map or not.\n                if (mp.count(val)) ans += mp[val];\n            }\n            // Inserting into map.\n            mp[nums[i]]++;\n        }\n        return ans;\n    }\n};\n\n```
['C++']