Easy || C++ || Brute force Code
Intuition\n Describe your first thoughts on how to solve this problem. \nSimple brute solution using set and map\n\n# Approach\n Describe your approach to solvi
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nSimple brute solution using set and map\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\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```cpp []\nclass Solution {\npublic:\n    set<int> f(int n){\n        string num = to_string(n);\n        set<int> st;\n        st.insert(n);\n        for(int i=0;i<num.size();i++){\n            for(int j=i+1;j<num.size();j++){\n                swap(num[i],num[j]);\n                int number = stoi(num);\n                st.insert(number);\n                for(int x=0;x<num.size();x++){\n                    for(int y=x+1;y<num.size();y++){\n                        swap(num[x],num[y]);\n                        int num2 = stoi(num);\n                        st.insert(num2);\n                        swap(num[x],num[y]);\n                    }\n                }\n                swap(num[i],num[j]);\n            }\n        }\n        return st;\n    }\n    int countPairs(vector<int>& nums) {\n        int n = nums.size();\n        vector<int> hsh(n,0);\n        sort(nums.begin(),nums.end());\n        int ct = 0;\n        map<int,int> mp;\n        for(int i=0;i<n;i++){\n            set<int> st = f(nums[i]);\n            for(auto it:st){\n                if(mp.find(it) != mp.end());\n                ct += mp[it];\n            }\n            mp[nums[i]]++;\n        }\n        return ct;\n    }\n};\n```
['C++']