Back to QuestionsPractice with This Question
Shortest Palindrome
67.1K views•Asked 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.