Implement strStr()

Easy
Strings String Two Pointers

Return the index of first occurrence of needle in haystack, or -1.

Constraints

0 ≤ lengths ≤ 5×10^4

Examples

Example 1:
Input: sadbutsad sad
Output: 0
Example 2:
Input: leetcode leeto
Output: -1
▲ Console

Install Talent Arabia

Get instant access to jobs and career tools on your device.