代码随想录:重复的子字符串
代码随想录:重复的子字符串
巧妙的思路,记住吧
class Solution {
public:
bool repeatedSubstringPattern(string s) {
if (s.size() == 1) {
return false;
}
string a = s + s;
a.erase(a.begin());
a.erase(a.end() - 1);
if (a.find(s) != a.npos) {
return true;
} else {
return false;
}
}
};