LeetCode28A是否是B的子串

------------恢复内容开始------------

# coding:utf-8
"""
Name : LeetCode28.py
Author  : qlb
Contect : 17801044486@163.com
Time    : 2021/2/7 17:17
Desc:实现 strStr()
"""
class Solution:
    def strStr(self, haystack: str, needle: str) -> int:
        haystack = list(haystack)
        needle = list(needle)
        for i in range(len(haystack) - len(needle) + 1):
            if needle == haystack[i:i+len(needle)]:
                return i
        else:
            return -1

------------恢复内容结束------------

原文地址:https://www.cnblogs.com/cnugis/p/14385973.html