My very simple Python solution (39 ms)


  • 0
    K
    class Solution(object):
        def strStr(self, haystack, needle):
            """
            :type haystack: str
            :type needle: str
            :rtype: int
            """
            
            if needle in haystack:
                return haystack.find(needle)
            else:
                return -1
    

Log in to reply
 

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