File tree Expand file tree Collapse file tree 1 file changed +7
-7
lines changed
Expand file tree Collapse file tree 1 file changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -8,17 +8,18 @@ https://leetcode-cn.com/problems/implement-strstr/
88## C++代码
99
1010```
11+
1112class Solution{
1213public:
1314 void preKmp(int* next, const string& s){
14- next[0]= -1;
15- int j= -1;
16- for(int i=1;i< s.size();i++){
17- while(j>= 0 && s[i]!= s[j+1])
15+ next[0] = -1;
16+ int j = -1;
17+ for(int i = 1; i < s.size(); i++){
18+ while(j >= 0 && s[i] != s[j+1])
1819 j = next[j];
19- if(s[i]== s[j+1])
20+ if(s[i] == s[j+1])
2021 j++;
21- next[i]= j;
22+ next[i] = j;
2223 }
2324 }
2425 int strStr(string haystack, string needle){
@@ -44,6 +45,5 @@ public:
4445 }
4546};
4647
47-
4848```
4949> 笔者在先后在腾讯和百度从事技术研发多年,利用工作之余重刷leetcode,本文 [ GitHub] ( https://github.com/youngyangyang04/leetcode-master ) :https://github.com/youngyangyang04/leetcode-master 已经收录,欢迎star,fork,共同学习,一起进步。
You can’t perform that action at this time.
0 commit comments