3
vector<int> get_kmp_table(const string &s) {4
vector<int> table(s.size());9
if (j == -1 || s[i] == s[j]) {20
bool validate_table(const vector<int> &table) {21
int idx = table.size() - 1;22
while (idx >= 0 && table[idx] > 0) {25
if (idx <= 0) return false;27
if (table.size() % substr_len != 0) return false;28
idx = idx + 1; // the first nonzero element in the string29
while (idx < table.size() - 1) {30
if (table[idx] != table[idx + 1] - 1) return false;36
bool repeatedSubstringPattern(string s) {37
if (s.size() <= 1) return true;39
auto table1 = get_kmp_table(s);41
reverse(ss.begin(), ss.end());42
auto table2 = get_kmp_table(ss);44
return (validate_table(table1) && validate_table(table2));