1.思路:快慢指针法
2.代码
class Solution:
def strStr(self, haystack, needle):
"""
:type haystack: str
:type needle: str
:rtype: int
"""
short=len(needle)
if short==0:
return 0
for i in range(len(haystack)):
if haystack[i]==needle[0]:
if haystack[i:i+short]==needle:
return i
return -1