题目链接:1078. Bigram 分词
from typing import List
class Solution:
def findOcurrences(self, text: str, first: str, second: str) -> List[str]:
words, thirds = text.split(), list()
for i in range(len(words) - 2):
if words[i] == first and words[i + 1] == second:
thirds.append(words[i + 2])
return thirds