1078. Occurrences After Bigram

Updated: 2024-03-12
1 min read
[]

On This Page

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