Solved 28. Find the Index of the First Occurrence in a String
This commit is contained in:
parent
707e68cf0a
commit
127c2a32f4
@ -0,0 +1,6 @@
|
||||
class Solution:
|
||||
def strStr(self, haystack: str, needle: str) -> int:
|
||||
for i in range(len(haystack)):
|
||||
if haystack[i:i+len(needle)] == needle:
|
||||
return i
|
||||
return -1
|
Loading…
Reference in New Issue
Block a user