首页 > 其他 > 详细

leetcode1065

时间:2019-06-02 10:04:29      阅读:98      评论:0      收藏:0      [点我收藏+]
 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]])

 

leetcode1065

原文:https://www.cnblogs.com/asenyang/p/10961836.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!