1554. Strings Differ by One Character

Обновлено: 2024-03-12
1 мин
[]

Содержание

LeetCode problem 1554

class Solution:
    def differByOne(self, dict: List[str]) -> bool:
        s = set()
        for word in dict:
            for i in range(len(word)):
                t = word[:i] + "*" + word[i + 1 :]
                if t in s:
                    return True
                s.add(t)
        return False