1 class Solution:
 2     def indexPairs(self, text: str, words: 'List[str]') -> 'List[List[int]]':
 3         result = list()
 4         n = len(text)
 5         for word in words:
 6             begin = 0
 7             while text.find(word,begin) >= 0:
 8                 idx = text.find(word,begin)
 9                 result.append([idx,idx+len(word)-1])
10                 begin = idx + 1
11 
12         return sorted(result,key=lambda x:[x[0],x[1]])

 

posted on 2019-06-02 06:24  Sempron2800+  阅读(238)  评论(0编辑  收藏  举报