<!--
 * @Description: 
 * @Autor: Au3C2
 * @Date: 2021-04-20 18:07:01
 * @LastEditors: Au3C2
 * @LastEditTime: 2021-04-20 18:08:59
-->
```python
class Solution:
    def strStr(self, haystack: str, needle: str) -> int:
        if not needle: 
            return 0
        n1, n2 = len(haystack), len(needle)
        for i in range(n1-n2+1):
            if haystack[i] == needle[0]:
                if haystack[i:i+n2] == needle:
                    return i
        return -1
```
字符串 简单 每日一题

写半天不如直接 `find`

```python
class Solution:
    def strStr(self, haystack: str, needle: str) -> int:
        return haystack.find(needle)
```