Lexicographically Smallest Equivalent String Problem can be found in here! Solution: Disjoint Set Time Complexity: , Space Complexity: , where n is the length of string s1 and $\alpha(\cdot)$ is the inverse ackermann function, which grows slowly.