KMP Algorithm
Knuth-Morris-Pratt precomputes how far to jump after a mismatch, using the pattern’s own borders. The text is never rewound.
Costs
| Category | Algorithm |
| Difficulty | Hard |
| Build the failure table | O(m) |
| Search | O(n) |
| Total | O(n + m) |
Questions
What is KMP Algorithm?
Knuth-Morris-Pratt precomputes how far to jump after a mismatch, using the pattern’s own borders. The text is never rewound.
Where do I practice it?
DSA Master keeps challenges and progress on the phone. This page is the idea and the costs.