Back to Questions

Shortest Palindrome

67.1K viewsAsked at Meta
Hard

Question Explain

Given a string $s$, find the shortest palindrome that can be formed by adding characters in front of it. Use KMP (Knuth-Morris-Pratt) preprocessing to find the longest palindromic prefix.

Start Trying This Question Simulation

Practice answering orally or with text to get instant AI feedback.

Practice with This Question