Shortest Palindrome
CodingML InfraNew
Examples
Example 1:
Input: s = "aacecaaa"
Output: aaacecaaa
Example 2:
Input: s = "abcd"
Output: dcbabcd
Example 1:
Input: s = "aacecaaa"
Output: aaacecaaa
Example 2:
Input: s = "abcd"
Output: dcbabcd
You are given a string s. You may add characters only to the front of the string.
Return the shortest palindrome you can build this way.
0 <= s.length <= 5 * 10^4s consists of lowercase English letters.