Categorygithub.com/szhou12/leetcode-goleetcode1061-Lexicographically-Smallest-Equivalent-String
package
0.0.0-20241220224003-b7cf03a90b2b
Repository: https://github.com/szhou12/leetcode-go.git
Documentation: pkg.go.dev

# README

1061. Lexicographically Smallest Equivalent String

Solution idea

Union Find

要点总结

  1. 思路比较直接的题目。题目已经明确给出 transitive 的性质,说明使用 Union Find 来解。字典序最小的显然就是每个 字符 所属component里的root。

Time complexity = $O(n)$ where n = max{s1.length, s2.length, baseStr.length}