题目链接:https://leetcode-cn.com/problems/repeated-substring-pattern/
暴力法:
class Solution {
public boolean repeatedSubstringPattern(String s) {
if(s.length() <= 1) return false;
for(int i=0;i<=(s.length()-1)/2;i++){
String t = s.substring(0,i+1);
if(s.length()%t.length() > 0) continue;//提前排除不可能重复的长度子串
boolean flag = true;
for(int j=0;j<s.length();j+=t.length()){
if(j+t.length() > s.length()) return false;
if(s.substring(j,j+t.length()).equals(t)==false){
flag = false;
break;
}
}
if(flag) return true;
}
return false;
}
}