Merge pull request #1479 from janeyziqinglin/master

更新 problems/0704.二分查找python版本; 更新0027.移除元素python版本;添加0977.有序数组的平方 python版本;添加0209.长度最小的子数组python版本;优化 0054.螺旋矩阵 python版本;更新面试题02.07.链表相交 python版本;优化0234.回文链表 python版本;优化0925.长按键入python版本
This commit is contained in:
程序员Carl
2022-07-22 09:54:56 +08:00
committed by GitHub
9 changed files with 148 additions and 108 deletions

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: