Shortest Palindrome
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.

30:00

Shortest Palindrome
hard
Topics
Companies

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.

Example 1:
Input: {"s":"aacecaaa"}
Output: aaacecaaa
Constraints:
  • 0s.length5×1040 \leq s.\text{length} \leq 5 \times 10^4

  • s consists of lowercase English letters only.

Input
arr ={"s":"aacecaaa"}

Reverse the string: "aaacecaa"

Input String

a

a

c

e

c

a

a

a

Reversed String

a

a

a

c

e

c

a

a

Input Length: 8
Variables
No variables to display
DepthFunction Call
Stack empty
0/3