admin管理员组

文章数量:1636968

Implement strStr 实现strStr

  • 题目
  • 解法1、
  • 出处

题目

解法1、

class Solution:
    def strStr(self, haystack: str, needle: str) -> int:
        for i in range(len(haystack) - len(needle) + 1):
            if haystack[i:i+len(needle)] == needle:
                return i
        return -1

出处

1、对应题目下Knife丶的题解

本文标签: PythonLeetCodestrStrimplement