find-the-iV2.py (409B)
1 class Solution: 2 def strStr(self, haystack: str, needle: str) -> int: 3 for i in range(0, 1 + len(haystack) - len(needle)): 4 if incremental_check(i, needle, haystack): 5 return i 6 return -1 7 8 9 def incremental_check(index, needle, haystack): 10 for itr in range(0, len(needle)): 11 if haystack[index + itr] != needle[itr]: 12 return False 13 return True