Minimum Insertion Steps to Make a String Palindrome

Given a string s. In one step you can insert any character at any index of the string.

Return the minimum number of steps to make s palindrome.

A Palindrome String is one that reads the same backward as well as forward.

Example 1
Inputs = "zzazz"
Output0
The string "zzazz" is already palindrome we do not need any insertions.
Example 2
Inputs = "mbadm"
Output2
String can be "mbdadbm" or "mdbabdm".

Constraints

  • 1 <= s.length <= 500
  • s consists of lowercase English letters.

Asked at 6 companies

</>

Your Solution

(Ctrl/Cmd + Enter)

Switching Language

Loading template...

Loading...

Sign in to save your progress

AI code evaluation

Get a correctness verdict, missed edge cases, and complexity analysis of your solution.

Sign in to evaluate