Skip to content

Commit 0069a6f

Browse files
Update
1 parent 1e6702f commit 0069a6f

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

‎problems/0028.实现strStr().md‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,18 @@ https://leetcode-cn.com/problems/implement-strstr/
88
## C++代码
99

1010
```
11+
1112
class Solution{
1213
public:
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,共同学习,一起进步。

0 commit comments

Comments
(0)