Skip to content

Commit

Permalink
手写
Browse files Browse the repository at this point in the history
  • Loading branch information
rinwf committed Sep 30, 2018
1 parent ed97edc commit ecc15e2
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lc28. Implement strStr().py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ def strStr(self, haystack, needle):
:type needle: str
:rtype: int
"""
return haystack.find(needle)
for i in range(len(haystack) - len(needle) + 1):
if haystack[i:i + len(needle)] == needle:
return i
return -1


haystack = "hello"
Expand Down

0 comments on commit ecc15e2

Please sign in to comment.