题目描述
给定一个
haystack
字符串和一个needle
字符串,在haystack
字符串中找出needle
字符串出现的第一个位置 (从0
开始)。如果不存在,则返回-1
。
示例1:
输入: haystack = "hello", needle = "ll"
输出: 2
示例2:
输入: haystack = "aaaaa", needle = "bba"
输出: -1
我的解
class Solution(object):
def strStr(self, haystack, needle):
"""
:type haystack: str
:type needle: str
:rtype: int
"""
return haystack.find(needle)