java.lang.Object
g1301_1400.s1312_minimum_insertion_steps_to_make_a_string_palindrome.Solution

public class Solution extends java.lang.Object
1312 - Minimum Insertion Steps to Make a String Palindrome.

Hard

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:

Input: s = “zzazz”

Output: 0

Explanation: The string “zzazz” is already palindrome we don’t need any insertions.

Example 2:

Input: s = “mbadm”

Output: 2

Explanation: String can be “mbdadbm” or “mdbabdm”.

Example 3:

Input: s = “leetcode”

Output: 5

Explanation: Inserting 5 characters the string becomes “leetcodocteel”.

Constraints:

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

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    minInsertions(java.lang.String s)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Solution

      public Solution()
  • Method Details

    • minInsertions

      public int minInsertions(java.lang.String s)