Python solution


  • 0
    S

    I don't quite understand what're the haystack and needle, but shouldn't it be:
    class Solution(object):
    def strStr(self, haystack, needle):
    """
    :type haystack: str
    :type needle: str
    :rtype: int
    """
    try:
    return haystack.index(needle)
    except:
    return -1

    Right?


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.