Leetcode 459 python 解题报告
2017-02-17 10:22
447 查看
AC代码:
思路:从1到length/2长度依次进行判断,发现满足情况的substring即可返回True.
class Solution(object): def repeatedSubstringPattern(self, str): """ :type str: str :rtype: bool """ for i in range(1,len(str)/2+1): if len(str)%i != 0: continue if self.issubstring(str,i): return True return False def issubstring(self,str,i): tmp = str[:i] for j in range(i,len(str),i): if tmp != str[j:j+i]: return False return True
思路:从1到length/2长度依次进行判断,发现满足情况的substring即可返回True.
相关文章推荐
- 【LeetCode】Reverse Linked List 解题报告(Python & java)
- 【LeetCode】Single Number 解题报告(Java & Python)
- 【LeetCode】Binary Tree Paths 解题报告(java & python)
- 【LeetCode】79. Word Search 解题报告(Python)
- 【LeetCode】791. Custom Sort String 解题报告(Python)
- 【LeetCode】Merge Two Sorted Lists 解题报告(Java & Python)
- Leetcode 399 python 解题报告
- 【LeetCode】Two Sum 解题报告(java & python)
- Leetcode 525 python 解题报告
- 【LeetCode】445. Add Two Numbers II 解题报告(Python)
- Leetcode 349. Intersection of Two Arrays 解题报告 Python Java
- Leetcode 494 python 解题报告
- Leetcode 424 python 解题报告
- 【LeetCode】129. Sum Root to Leaf Numbers 解题报告(Python)
- 景岁的Leetcode解题报告:283. Move Zeroes(Python)
- 【LeetCode】Hamming Distance 解题报告(java & python)
- Leetcode 451 python 解题报告
- Leetcode 486 python 解题报告
- 【LeetCode】2. Add Two Numbers 解题报告(Python)
- 【LeetCode】788. Rotated Digits 解题报告(Python)