python 4 line beat 87%


  • 0
    Y

    '''
    class Solution(object):
    def strStr(self, haystack, needle):
    """
    :type haystack: str
    :type needle: str
    :rtype: int
    """
    try:
    return haystack.index(needle)
    except ValueError:
    return -1
    '''


Log in to reply
 

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