28. 找出字符串中第一个匹配项的下标 - 力扣(LeetCode)
暴力解法:
class Solution(object):
def strStr(self, haystack, needle):
if needle not in haystack:
return -1
n=len(needle)
for i in range(len(haystack)):
if haystack[i:i+n] == needle:
return i