1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| class Solution { public boolean repeatedSubstringPattern(String s) { int n = s.length(); for (int i = 1; i*2 <= n; i++) { if (n % i == 0){ Boolean bool = true; for (int j = i; j < n; j++) { if (s.charAt(j - i) != s.charAt(j)) { bool = false; break; } } if (bool) { return true; } } } return false; } }
|