We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 5629e93 commit e299914Copy full SHA for e299914
.DS_Store
-2 KB
leetcode/solution/src/RepeatedSubstringPattern.java
@@ -5,15 +5,20 @@ public class RepeatedSubstringPattern {
5
*/
6
public boolean repeatedSubstringPattern(String str) {
7
int l = str.length();
8
+ boolean flag = true;
9
for (int i = l / 2; i >= 1; i--) {
10
if (l % i == 0) {
11
int m = l / i;
12
+ if (m % 2 == 0 && !flag) {
13
+ continue;
14
+ }
15
String subS = str.substring(0, i);
16
StringBuilder sb = new StringBuilder();
17
for (int j = 0; j < m; j++) {
18
sb.append(subS);
19
}
20
if (sb.toString().equals(str)) return true;
21
+ flag = false;
22
23
24
return false;
0 commit comments