Practice Shortest Palindrome
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
You are given a string s. You can convert s to a palindrome by adding characters in front of it. Return the shortest palindrome you can find by performing this transformation.
Source: Shortest Palindrome on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Input
s = "aacecaaa"
Output
"aaacecaaa"
# Example 2
Input
s = "abcd"
Output
"dcbabcd"
Constraints
0 <= s.length <= 5 * 10^4
s consists of lowercase English letters only.
Related LeetCode Problems
Practice more problems similar to Shortest Palindrome.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.