1668. 最大重复子字符串
动态规划
class Solution {
public:
int maxRepeating(string sequence, string word) {
int sequenceLength = sequence.length(), wordLength = word.length();
if(sequenceLength < wordLength){
return 0;
}
// 1. 确定状态含义:
// f[i]表示第i个位置作为结束位置,前wordLength长度的字符串是word时的最大重复值
// 如果前wordLength长度的字符串不是word,则f[i]=0,表示以i结束的字符串中最大重复值没有发生变化
vector<int> f(sequenceLength, 0);
// 2. base状态定义
// 如果sequence的前wordLength长度的字符串是word,那么f[wordLength - 1] = 1
if(sequence.substr(0, wordLength)