Skip to content

Commit bbb65f1

Browse files
Merge pull request seeditsolution#363 from SushilG96/new-code
Adding solution for Repeated Substring Pattern problem
2 parents 4864e06 + aab9dc5 commit bbb65f1

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

Repeated_Substring_Pattern.py

Lines 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)