def repeatedSubstringPattern(self, str):
:type str: str
ss = (str*2)[1:-1]
return str in ss
@icemanwang Brilliant! But can you explain why this pattern is correct? And I curious how you came up with it. Thank you!
@zzzzzgo basically, if there is a repeated pattern, there should be at least two same instances, including one in first half and another in second half. This code is to check whether it is at least this case.
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.