Implement the KMP (Knuth-Morris-Pratt) algorithm for substring matching.
HardProblem Statement
Implement the KMP (Knuth-Morris-Pratt) algorithm for substring matching.
Sample Input
Text: "abcabcabdabc"; Pattern: "abcabd"
Sample Output
Pattern found at index 3
Limits
Time: 2s · Memory: 256 MB