码迷,mamicode.com
首页 > 其他好文 > 详细

leetcode——459. 重复的子字符串

时间:2019-10-18 16:09:06      阅读:69      评论:0      收藏:0      [点我收藏+]

标签:das   重复   执行   result   span   else   用户   ret   inf   

简单题,效果不够好

class Solution:
    def repeatedSubstringPattern(self, s: str) -> bool:
        a=‘‘
        for i in range(len(s)):
            if s[i] not in a:
                a+=s[i]
            else:
                if a == s[i:i+len(a)]:
                    if s==a*(len(s)//len(a)):
                        return True
                    else:
                        a+=s[i]
                else:
                    a+=s[i]
        return False
执行用时 :184 ms, 在所有 python3 提交中击败了19.12%的用户
内存消耗 :13.8 MB, 在所有 python3 提交中击败了5.08%的用户
 
                                                                                   ——2019.10.18

leetcode——459. 重复的子字符串

标签:das   重复   执行   result   span   else   用户   ret   inf   

原文地址:https://www.cnblogs.com/taoyuxin/p/11698324.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!