遍历遍历遍历 ```python class Solution: def strStr(self, haystack, needle): """ :type haystack: str :type needle: str :rtype: int """ if len(needle) == 0: return 0 needle_len = len(needle) haystack_len = len(haystack) if needle_len > haystack_len: return -1 for index in range(haystack_len - needle_len + 1): find = 0 for s2 in needle: if haystack_len > find + index and s2 == haystack[find + index]: find += 1 else: break if find == needle_len: return index return -1 ```
Activity