70. Find a Substring (KMP)
MediumString algorithms
Return the index of the first occurrence of needle in haystack, or -1. Do not use built-in search methods; aim for O(n + m).
Example 1
Input: haystack = "sadbutsad", needle = "sad" Output: 0
Constraints
1 ≤ haystack.length, needle.length ≤ 10⁴