Tap here to switch tabs
Problem
Submissions

Problem: Shortest Palindrome

med
30 min
Try to solve the Shortest Palindrome problem.

Statement

Given a string s, you may prepend any number of characters to the front of s to make it a palindrome.

Return the shortest palindrome that can be formed by only prepending characters to s.

Constraints:

  • 0≤0 \leq s.length ≤5×104\leq 5 \times 10^4

  • s consists of lowercase English letters only

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Shortest Palindrome

med
30 min
Try to solve the Shortest Palindrome problem.

Statement

Given a string s, you may prepend any number of characters to the front of s to make it a palindrome.

Return the shortest palindrome that can be formed by only prepending characters to s.

Constraints:

  • 0≤0 \leq s.length ≤5×104\leq 5 \times 10^4

  • s consists of lowercase English letters only