- Problem Number: 214
- Problem Link: https://leetcode.com/problems/shortest-palindrome/
- Difficulty: Hard
- Topics: String, Rolling Hash, String Matching, Hash Function
Given a string s, you can convert it to a palindrome by adding characters in front of it.
Return the shortest palindrome you can find by performing this transformation.
Note:
- A palindrome is a string that reads the same forward and backward
- You can only add characters to the front of the string
Input: s = "aacecaaa"
Output: "aaacecaaa"
Input: s = "abcd"
Output: "dcbabcd"
- 0 <= s.length <= 5 * 10⁴
- s consists of lowercase English letters only