Python 6 line solution


  • 0
    I
    class Solution(object):
        def strStr(self, haystack, needle):
    	if needle in haystack:
    	    return haystack.index(needle)
    	else:
    	    return -1
    

    Quick, easy, and painless.


Log in to reply
 

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