Skip to content

Commit ea0c138

Browse files
authored
Update implement-strstr.py
1 parent 341f747 commit ea0c138

File tree

1 file changed

+2
-11
lines changed

1 file changed

+2
-11
lines changed

Python/implement-strstr.py

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,6 @@ def getPrefix(self, pattern):
4444
prefix[i] = j
4545
return prefix
4646

47-
def strStr2(self, haystack, needle):
48-
"""
49-
:type haystack: str
50-
:type needle: str
51-
:rtype: int
52-
"""
53-
try:
54-
return haystack.index(needle)
55-
except:
56-
return -1
5747

5848
# Time: O(n * k)
5949
# Space: O(k)
@@ -68,7 +58,8 @@ def strStr(self, haystack, needle):
6858
if haystack[i : i + len(needle)] == needle:
6959
return i
7060
return -1
71-
61+
62+
7263
if __name__ == "__main__":
7364
print Solution().strStr("a", "")
7465
print Solution().strStr("abababcdab", "ababcdx")

0 commit comments

Comments
 (0)