Implement strStr()
Question
Answer
solution:this is done by meself
class Solution(object):
def strStr(self, haystack, needle):
"""
:type haystack: str
:type needle: str
:rtype: int
"""
for i in xrange(0,len(haystack)-len(needle)+1):
if haystack[i:i+len(needle)] == needle:
return i
return -1Knowledge:
Last updated