Back to Question

Shortest Palindrome

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

Click "Start Speaking" and answer the question naturally.