Coder's Cat

2020-01-31

## Description

Implement strStr().

Return the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.

Example 1:

Example 2:

## C++ Solution

Time complexity: $O(MN)$ where M and N are the lengths of two string.

## Python Solution

Use str[i:length] to get the sub-string of str.

Preparing for an interview? Check out this!