看题解的KMP自己手动实现太难了,我还是选择容易理解的暴力枚举叭
class Solution {
public:
bool isCheck(string subs, string s) {
if(s.size() % subs.size() != 0) return false;
int k = s.size() / subs.size();
string comp = "";
while(k--) {
comp += subs;
}
return comp == s;
}
bool repeatedSubstringPattern(string s) {
if(s.size() == 1) return false;
for(int i = 1; i <= s.size() / 2; i++) {
if(isCheck(s.substr(0,i),s)) return true;
}
return false;
}
};