459. Repeated Substring Pattern

Given a string s, check if it can be constructed by taking a substring of it and appending multiple copies of the substring together.

Example 1:

Input: s = "abab"
Output: true
Explanation: It is the substring "ab" twice.

Example 2:

Input: s = "aba"
Output: false

Example 3:

Input: s = "abcabcabcabc"
Output: true
Explanation: It is the substring "abc" four times or the substring "abcabc" twice.

def repeatedSubstringPattern(self, s: str) -> bool:
	new=s+s
	new=new[1:-1]
	if s in new:
		return True
	else:
		return False
def repeatedSubstringPattern(self, s: str) -> bool:
	l = len(s)
	if l == 1:
		return False
	m = l // 2
	i = 1
	while i <= m:
		if s[:i] * (l // i) == s:
			return True
		i += 1
	return False %%