LeetCode28:https://leetcode-cn.com/problems/implement-strstr/submissions/
解题思路:滑动窗法
1 class Solution: 2 def strStr(self, haystack: str, needle: str) -> int: 3 len1 = len(haystack) 4 len2 = len(needle) 5 for i in range(len1-len2+1): 6 if haystack[i:i+len2] == needle: 7 return i 8 return -1