添加0028.实现strStr python版本暴力解法

This commit is contained in:
JaneyLin
2022-06-16 21:24:24 -05:00
committed by GitHub
parent 177823b119
commit 0b9737d754

View File

@ -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: