class Solution:
def strStr(self, haystack: str, needle: str) -> int:
length=len(needle)
for i in range(len(haystack)-length+1):
if needle==haystack[i:i+length]:
return i
return -1 if needle else 0
leetcode刷题python之实现strStr()
最新推荐文章于 2021-04-20 16:24:00 发布