459. 重复的子字符串
KMP算法一点都不想回忆了,等找实习的时候再仔细看吧
class Solution {
public:
bool repeatedSubstringPattern(string s) {
if(s.size() <= 1) return false;
string temp = "", str = "";
for(int i = 0; i < s.size() / 2; ++i){
temp += s[i];
while(str.size() <= s.size()){
str += temp;
if(str == s) return true;
}
str = "";
}
return false;
}
};