Home
Topics
Practice
Roadmap
DSA Tracker
Code Editor
Tech Blogs
More
Sign in
Get started
Loading question...
Feedback
Shortest Palindrome
Medium
00:00
0 users online
Share
Description
Solution
Submissions
Discussion
Given a string, find and return the shortest palindrome by adding characters in front.
Sample Input:
"aacecaaa"
Sample Output:
"aaacecaaa"
Hints
Hint 1
Find longest palindrome prefix
Hint 2
Use KMP algorithm on s + "#" + reverse(s)
Hint 3
Add reverse of suffix to front
Code Editor
Reset
Run
Save
Loading...