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

简单题,效果不够好

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

猜你喜欢

转载自www.cnblogs.com/taoyuxin/p/11698324.html