java.lang.Object
g1301_1400.s1312_minimum_insertion_steps_to_make_a_string_palindrome.Solution

public class Solution extends Object
1312 - Minimum Insertion Steps to Make a String Palindrome.<p>Hard</p> <p>Given a string <code>s</code>. In one step you can insert any character at any index of the string.</p> <p>Return <em>the minimum number of steps</em> to make <code>s</code> palindrome.</p> <p>A <strong>Palindrome String</strong> is one that reads the same backward as well as forward.</p> <p><strong>Example 1:</strong></p> <p><strong>Input:</strong> s = &ldquo;zzazz&rdquo;</p> <p><strong>Output:</strong> 0</p> <p><strong>Explanation:</strong> The string &ldquo;zzazz&rdquo; is already palindrome we don&rsquo;t need any insertions.</p> <p><strong>Example 2:</strong></p> <p><strong>Input:</strong> s = &ldquo;mbadm&rdquo;</p> <p><strong>Output:</strong> 2</p> <p><strong>Explanation:</strong> String can be &ldquo;mbdadbm&rdquo; or &ldquo;mdbabdm&rdquo;.</p> <p><strong>Example 3:</strong></p> <p><strong>Input:</strong> s = &ldquo;leetcode&rdquo;</p> <p><strong>Output:</strong> 5</p> <p><strong>Explanation:</strong> Inserting 5 characters the string becomes &ldquo;leetcodocteel&rdquo;.</p> <p><strong>Constraints:</strong></p> <ul> <li><code>1 <= s.length <= 500</code></li> <li><code>s</code> consists of lowercase English letters.</li> </ul>
  • Constructor Details

    • Solution

      public Solution()
  • Method Details

    • minInsertions

      public int minInsertions(String s)