Pages in String
Algorithm Question Substring Search KMP
Question LeetCode has this question Implement strStr(). Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack. Tags: Two Pointers, String. Let’s denote haystack length N, needle length M, character table size R (256 for extended ASCII). Java’s String class method indexOf() uses brute force algorithm O(MN). Examples: haystacsflksdjflkshhaystackneeneeneedle needle naslkfjskjlhhhh needle Method 1 2D DFA KMP Knuth Morris Pratt O(N) time complexity.