5 line solution for python


  • 0
    J

    def strStr(self, haystack, needle):
    """
    :type haystack: str
    :type needle: str
    :rtype: int
    """
    if needle in haystack:
    result=haystack.find(needle)
    else:
    result=-1
    return result


Log in to reply
 

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