class Solution:
def findOcurrences(self, text: str, first: str, second: str) -> List[str]:
res = []
list_items = text.split(' ')
for i in range(len(list_items)-2):
if list_items[i] == first and list_items[i+1] == second:
res.append(list_items[i+2])
return res
LeetCode 1078 Bigram分词
最新推荐文章于 2024-08-17 20:25:49 发布