FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
algorithms/algorithms/strings/repeat_substring.py at master · lualgorithm/algorithms · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
lualgorithm
/
algorithms
Public
forked from
keon/algorithms
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
algorithms
/
algorithms
/
strings
/
repeat_substring.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
25 lines (21 loc) · 549 Bytes
Breadcrumbs
algorithms
/
algorithms
/
strings
/
repeat_substring.py
Copy path
File metadata and controls
25 lines (21 loc) · 549 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
"""
Given a non-empty string check if it can be constructed by taking
a substring of it and appending multiple copies of the substring together.
For example:
Input: "abab"
Output: True
Explanation: It's the substring "ab" twice.
Input: "aba"
Output: False
Input: "abcabcabcabc"
Output: True
Explanation: It's the substring "abc" four times.
Reference: https://leetcode.com/problems/repeated-substring-pattern/description/
"""
def
repeat_substring
(
s
):
"""
:type s: str
:rtype: bool
"""
str
=
(
s
+
s
)[
1
:
-
1
]
return
s
in
str
Back
|
FazBrowse Home
|
New Git URL