From aab9dc5b448498ff1cedafb3944561050a28db76 Mon Sep 17 00:00:00 2001 From: Sushil Gupta Date: Sat, 3 Oct 2020 16:54:33 +0530 Subject: [PATCH] Adding solution for Repeated Substring Pattern problem --- Repeated_Substring_Pattern.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 Repeated_Substring_Pattern.py diff --git a/Repeated_Substring_Pattern.py b/Repeated_Substring_Pattern.py new file mode 100644 index 0000000..4855729 --- /dev/null +++ b/Repeated_Substring_Pattern.py @@ -0,0 +1,18 @@ +class Solution: + def repeatedSubstringPattern(self, s: str) -> bool: + cal = run = 0 + tem = s[:cal] + for i in range(len(s)): + cal += 1 + tem = s[:cal] + + # Jump is with the size of searching elelment i.e cal + for j in range(cal, len(s), cal): + if tem == s[j: j + cal]: + run = j + cal + if run == len(s): + return True + else: + break + return False +