Skip to content

Commit

Permalink
添加0028.实现strStr python版本暴力解法
Browse files Browse the repository at this point in the history
  • Loading branch information
janeyziqinglin committed Jun 17, 2022
1 parent 177823b commit 0b9737d
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion problems/0028.实现strStr.md
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,21 @@ class Solution {
```

Python3:

```python
//暴力解法:
class Solution(object):
def strStr(self, haystack, needle):
"""
:type haystack: str
:type needle: str
:rtype: int
"""
m,n=len(haystack),len(needle)
for i in range(m):
if haystack[i:i+n]==needle:
return i
return -1
```
```python
// 方法一
class Solution:
Expand Down

0 comments on commit 0b9737d

Please sign in to comment.