leetcode 1061 python1 [LeetCode] 1061. Lexicographically Smallest Equivalent String (파이썬/python) 🎈문제 https://leetcode.com/problems/lexicographically-smallest-equivalent-string/description/ 🎁어떤 알고리즘? 1. union-find 알고리즘 -> 두 번째 풀어보는 union-find문제. 이전에는 리스트의 idx에 값을 저장하여 부모 노드를 찾아줬는데, 이번 문제에서는 숫자가 아닌 str()이여서 리스트의 65번째 idx부터 활용해야하나 고민했지만 검색을 조금 해보니 dict를 활용하는 좋은 방법이 있었다. 💻코드 class Solution: def smallestEquivalentString(self, s1: str, s2: str, baseStr: str) -> str: def find(x): if x not in paren.. 2023. 8. 10. 이전 1 다음