1078. Bigram 分词
为保证权益,题目请参考 1078. Bigram 分词(From LeetCode).
解决方案1
Python
python
# 1078. Bigram 分词
# https://leetcode-cn.com/problems/occurrences-after-bigram/
class Solution:
def findOcurrences(self, text: str, first: str, second: str) -> List[str]:
ans = []
text = text.split(" ")
for i in range(len(text)-2):
if text[i] == first and text[i+1] == second:
ans.append(text[i+2])
return ans
1
2
3
4
5
6
7
8
9
10
11
12
2
3
4
5
6
7
8
9
10
11
12