Python两行代码搞定
class Solution:
def findOcurrences(self, text: str, first: str, second: str) -> List[str]:
words = text.split()
return [words[i] for i in range(2, len(words)) if words[i - 2] == first and words[i - 1] == second]
Python两行代码搞定
class Solution:
def findOcurrences(self, text: str, first: str, second: str) -> List[str]:
words = text.split()
return [words[i] for i in range(2, len(words)) if words[i - 2] == first and words[i - 1] == second]