1078. Occurrences After Bigram

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

Содержание

LeetCode problem 1078

class Solution:
    def findOcurrences(self, text: str, first: str, second: str) -> List[str]:
        words = text.split()
        res = []
        for i in range(len(words) - 2):
            a, b, c = words[i : i + 3]
            if a == first and b == second:
                res.append(c)
        return res