C++ Easy Solution using DSU(disjoint set Union)
Intuition\n Describe your first thoughts on how to solve this problem. \nFor every character c in baseStr we need to find minimum equivalent valued character. A
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nFor every character c in baseStr we need to find minimum equivalent valued character. As relation is equivalence ie. Reflexive, Symmetric and Transitive there can be multiple characters related to a single character in baseStr. Thus to maintain this Ive used Disjoint Set Union(Disjoint Set Union).\n# Approach\n<!-- Describe your approach to solving the problem. -->\nSo incase you dont know DSU let me brief up a little.\n- It has a parent array to store parent of a node.\n- Then there are two functions :\n  - findSet(int node ) to find parent of a node.\n  - Union(int node1,int node2) to connect to node and update parent of the nodes. \n\n#### Furthermore, the code I used is only lil bit different from Standard DSU code. It is obvious we need to find minimum equivalent character, so parent of the nodes must be chosen as the minimum character.\n ***Parent here stores the minimum equivalent character**\n# **Steps:**\n- For simplicity Ive used map to store parent of character based on given strings s1 and s2.\n- Initiallly parent of character is itself.\n- Now we just need to union the characters of s1 and s2 while comparing which of these has minimum equivalent character and then updating the parent of both.\n- Lastly we can use find_set() to find minimum equivalent character for each cahracter of baseStr.\n\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\nO(nlogn) because of map being used\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\nO(nlogn) \n# Code\n```\nclass Solution {\npublic:\n    char find_set(char c,map<char,char>& parent)\n    {\n        if(parent[c]==c) return c;\n        else \n        {\n            return parent[c]=find_set(parent[c],parent);\n        }\n    }\n\n    void union_set(map<char,char>& parent,char c1,char c2){\n        int p1=find_set(c1,parent);\n        int p2=find_set(c2,parent);\n\n        if(p1<p2)\n        {\n            parent[p2]=p1;\n        }\n\n        else{\n            parent[p1]=p2;\n        }\n    }\n\n    string smallestEquivalentString(string s1, string s2, string baseStr) {\n        map<char,char> parent;\n        for(int i=0;i<26;i++)\n        {\n            parent[char(i+\'a\')]= char(i+\'a\');\n        }\n\n        int n=s1.size();\n        for(int i=0;i<n;i++)\n        {\n            union_set(parent,s1[i],s2[i]);\n        }\n\n        int l=baseStr.size();\n        string req="";\n        for(int i=0;i<l;i++)\n        {\n            req+=find_set(baseStr[i],parent);\n        }\n\n        return req;\n\n    }\n};\n```
['Graph', 'C++']