leetcode1078

1 class Solution:
2     def findOcurrences(self, text: str, first: str, second: str) -> 'List[str]':
3         ary = text.split(' ')
4         n = len(ary)
5         result = list()
6         for i in range(n):
7             if ary[i] == first and i+1<n-1 and ary[i+1] == second:
8                 result.append(ary[i+2])
9         return result

猜你喜欢

转载自www.cnblogs.com/asenyang/p/10994614.html
今日推荐