Hard · Strings

Minimum Insertions to Form a Palindrome

Given a string s, return the minimum number of characters that must be inserted (at any positions) to make s a palindrome.

Examples

Example 1

{
  "s": "notebook"
}

Output: 5 insertions

Example 2

{
  "s": "mbadm"
}

Output: 2 insertions

Rebuild it in the studio

Read every interview problem free. Ten rooms need no account. A token opens a problem in full — Pro never counts.

More Strings problems