Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit aab9dc5

Browse filesBrowse files
committed
Adding solution for Repeated Substring Pattern problem
1 parent f581e7e commit aab9dc5
Copy full SHA for aab9dc5

File tree

Expand file treeCollapse file tree

1 file changed

+18
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+18
-0
lines changed
Open diff view settings
Collapse file

‎Repeated_Substring_Pattern.py‎

Copy file name to clipboard
+18Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
class Solution:
2+
def repeatedSubstringPattern(self, s: str) -> bool:
3+
cal = run = 0
4+
tem = s[:cal]
5+
for i in range(len(s)):
6+
cal += 1
7+
tem = s[:cal]
8+
9+
# Jump is with the size of searching elelment i.e cal
10+
for j in range(cal, len(s), cal):
11+
if tem == s[j: j + cal]:
12+
run = j + cal
13+
if run == len(s):
14+
return True
15+
else:
16+
break
17+
return False
18+

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.