o(1) space and o(n) time solution using graph in python.
Intuition\nThink a graph with 26 nodes of alphabets.\n\n# Approach\n1>Think that s1[i],s2[i] represents the edge between two nodes.\n2>construct a graph using t
# Intuition\nThink a graph with 26 nodes of alphabets.\n\n# Approach\n1>Think that s1[i],s2[i] represents the edge between two nodes.\n2>construct a graph using these edges.\n3>In a connected component , smallest alphabet will asign to all.\n4>it can be done by asigning component number to each alphabet and smallest alphabet can be stored in corresponding to each component number via hashmap.\n# Complexity\n- Time complexity:\no(len(s1)+len(baseStr))\n\n- Space complexity:\no(1)(space of all hashmaps can be assumed as constant as size is only 26,assuming space for returning string will be require ,as string are immutable in python.)\n\n# Code\n```\nfrom collections import deque\nclass Solution:\n    def smallestEquivalentString(self, s1: str, s2: str, baseStr: str) -> str:\n        d={}\n        v={}\n        for i in range(26):\n            d[chr(i+97)]=[chr(i+97)]\n            v[chr(i+97)]=0\n        for i in range(len(s1)):\n            d[s1[i]].append(s2[i])\n            d[s2[i]].append(s1[i])\n        c=1\n        ans={}\n        for x in v:\n            if v[x]==0:\n                t=deque(x)\n                temp=x\n                while t:\n                    te=t.popleft()\n                    temp=min(temp,te)\n                    for i in range(len(d[te])):\n                        if v[d[te][i]]==0:\n                            v[d[te][i]]=c \n                            t.append(d[te][i])\n                ans[c]=temp\n                c+=1\n        s=""\n        for i in range(len(baseStr)):\n            s+=ans[v[baseStr[i]]]\n        return s\n\n                \n\n\n        \n```
['Hash Table', 'Breadth-First Search', 'Graph', 'Python', 'Python3']