We’re preparing your current view and syncing the latest data.
You are given a string s. You need to transform it into the shortest palindrome by adding characters only to the front of the string. Return the shortest palindrome you can find following this rule.
Example: Input: "aacecaaa" Output: "aaacecaaa"
Explanation: By adding 'a' in front of the original string, the string becomes a palindrome and is the shortest possible.
A single string s consisting of lowercase English letters.
Return the shortest palindrome string formed by adding characters in front of s.
1 <= s.length <= 10^5 s consists of lowercase English letters only.