Hard

Quiz

#214 Shortest Palindrome

APPROACH

Given a string s, prepend the fewest characters needed to turn it into a palindrome and return the result.

Example 1:

Input: s = "aacecaaa"
Output: "aaacecaaa"

Example 2:

Input: s = "abcd"
Output: "dcbabcd"
1 of 4
1:00

What is the optimal approach for this problem?