mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-08 08:50:15 +08:00
Update
This commit is contained in:
@ -15,10 +15,12 @@ public:
|
|||||||
next[0] = -1;
|
next[0] = -1;
|
||||||
int j = -1;
|
int j = -1;
|
||||||
for(int i = 1; i < s.size(); i++){
|
for(int i = 1; i < s.size(); i++){
|
||||||
while(j >= 0 && s[i] != s[j+1])
|
while (j >= 0 && s[i] != s[j + 1]) {
|
||||||
j = next[j];
|
j = next[j];
|
||||||
if(s[i] == s[j+1])
|
}
|
||||||
|
if (s[i] == s[j + 1]) {
|
||||||
j++;
|
j++;
|
||||||
|
}
|
||||||
next[i] = j;
|
next[i] = j;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user