Skip to content

Commit 5a16320

Browse files
committed
update
1 parent 036f65f commit 5a16320

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

Diff for: Python/implement-strstr.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,17 @@ class Solution:
1414
# @param needle, a string
1515
# @return a string or None
1616
def strStr(self, haystack, needle):
17+
if not needle:
18+
return 0
19+
1720
if len(haystack) < len(needle):
18-
return None
19-
20-
if len(needle) == 0:
21-
return haystack
21+
return -1
2222

2323
i = self.KMP(haystack, needle)
2424
if i > -1:
25-
return haystack[i:]
25+
return i
2626
else:
27-
return None
27+
return -1
2828

2929
def KMP(self, text, pattern):
3030
prefix = self.getPrefix(pattern)

0 commit comments

Comments
 (0)