diff --git a/problems/0028.实现strStr.md b/problems/0028.实现strStr.md index 1cdd5292..00997907 100644 --- a/problems/0028.实现strStr.md +++ b/problems/0028.实现strStr.md @@ -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: