➡️➡️✅Brute Force Approach
\n# Complexity\n- Time complexity:\n Add your time complexity here, e.g. O(n) \n    O(N3)\n- Space complexity:\n Add your space complexity here, e.g. O(n) \n   
\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n    O(N3)\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n    O(N2)\n# Code\n```\nclass Solution {\npublic:\n    string smallestEquivalentString(string s1, string s2, string b) {\n        map<char,set<char>>mp;\n        int n=s1.length();\n        for(int i=0;i<n;i++){\n            if(mp.find(s1[i])==mp.end()){\n                mp.insert({s1[i],{s1[i]}});\n            }\n             if(mp.find(s2[i])==mp.end()){\n                mp.insert({s2[i],{s2[i]}});\n            }\n            mp.find(s2[i])->second.insert(s1[i]);\n            mp.find(s1[i])->second.insert(s2[i]);\n        }\n\n        for(int i=0;i<n;i++){\n            set<char>num=mp.find(s1[i])->second;\n            for(auto a:num){\n                mp.find(a)->second.insert(s1[i]);\n                set<char>num2=mp.find(a)->second;\n                for(auto c:num2){\n                    mp.find(s1[i])->second.insert(c);\n                }\n            }\n            num=mp.find(s2[i])->second;\n            for(auto a:num){\n                mp.find(a)->second.insert(s2[i]);\n                set<char>num2=mp.find(a)->second;\n                for(auto c:num2){\n                    mp.find(s2[i])->second.insert(c);\n                }\n            }\n            num=mp.find(s1[i])->second;\n            for(auto a:num){\n                mp.find(s2[i])->second.insert(a);\n            }\n            num=mp.find(s2[i])->second;\n            for(auto a:num){\n                mp.find(s1[i])->second.insert(a);\n            }\n            \n            \n        }\n        string s="";\n        for(auto a:b){\n            if(mp.find(a)!=mp.end())\n            s.push_back(*(mp.find(a)->second.begin()));\n            else s.push_back(a);\n        }\n        return s;\n    }\n};\n```
['C++']