mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-09 19:44:45 +08:00
添加0028.实现strStr python版本暴力解法
This commit is contained in:
@ -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:
|
||||
|
Reference in New Issue
Block a user