When to use it
Reach for KMP / Z-algo ideas when a strings problem matches the cues in this lesson — especially after you’ve ruled out a brute-force nested scan.
Pattern
KMP / Z-algo ideas is a reusable approach under Strings. Once you recognize the shape of the input and the ask, this pattern gives you a standard plan instead of inventing a new algorithm from scratch.
Reach for KMP / Z-algo ideas when a strings problem matches the cues in this lesson — especially after you’ve ruled out a brute-force nested scan.
Reference implementation in C#, Python, Java, JavaScript, and C++.
Interviewers grade pattern recognition. Naming KMP / Z-algo ideas early shows you can classify the problem inside Fundamentals.
Drill KMP / Z-algo ideas with Strings problems — filter the bank and solve 2–3 Easy/Medium items while saying the invariant out loud.
Related Strings problems — open any one and apply KMP / Z-algo ideas.
Longest Substring Without Repeating Characters
Sliding Window
Longest Palindromic Substring
DP / Expand
Zigzag Conversion
Simulation
String to Integer (atoi)
Parsing
Regular Expression Matching
DP
Integer to Roman
Greedy
Roman to Integer
Greedy
Longest Common Prefix
String
Letter Combinations of a Phone Number
Backtracking