Search⌘ K
AI Features

Solution: Shortest Palindrome

Let's solve the Shortest Palindrome problem using the Knowing What to Track pattern.

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:

  • 00 \leq s.length ...