Given two strings haystack and needle, return the index of the first occurrence of needle in haystack, or -1 when it is not part of it.
haystack
needle
-1
haystack = "sadbutsad", needle = "sad"
0
haystack = "leetcode", needle = "leeto"
1 <= haystack.length, needle.length <= 10^4
Topics
Implement strStr in the editor and return the answer — printing it is never graded.
strStr
Problem 42 of 1146 in the arena