代码随想录算法训练营第10天|459

50 阅读1分钟

459

class Solution {
public:
    bool repeatedSubstringPattern(string s) {
        string t = s + s;
        t.erase(t.begin());
        t.erase(t.end() - 1);
        if ( t.find(s) != string::npos) return true;
        return false;

    }
};

总结:

看懂了,但是还是有点迷糊,暂时采用向右移动一位的方式理解next数组,下一轮再消化其他两种方式.