Practice Real Company Assessment Patterns • Latest 2025–2026 Mock Tests

Programming Exercises

Implement the KMP (Knuth-Morris-Pratt) algorithm for substring matching.

Hard

Problem 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

Code Editor
00:00
using System; class KMPSubstringSearch { static void Main() { // Implement the KMP algorithm for substring matching } }
Log in or sign up to run or submit your code.Log inSign up
Input
Text: "abcabcabdabc"; Pattern: "abcabd"
Expected Output
Pattern found at index 3