<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>&nbsp;palindrome.</p>

<p>A&nbsp;<b>Palindrome String</b>&nbsp;is one that reads the same backward as well as forward.</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>

<pre>
<strong>Input:</strong> s = &quot;zzazz&quot;
<strong>Output:</strong> 0
<strong>Explanation:</strong> The string &quot;zzazz&quot; is already palindrome we do not need any insertions.
</pre>

<p><strong class="example">Example 2:</strong></p>

<pre>
<strong>Input:</strong> s = &quot;mbadm&quot;
<strong>Output:</strong> 2
<strong>Explanation:</strong> String can be &quot;mbdadbm&quot; or &quot;mdbabdm&quot;.
</pre>

<p><strong class="example">Example 3:</strong></p>

<pre>
<strong>Input:</strong> s = &quot;leetcode&quot;
<strong>Output:</strong> 5
<strong>Explanation:</strong> Inserting 5 characters the string becomes &quot;leetcodocteel&quot;.
</pre>

<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
	<li><code>1 &lt;= s.length &lt;= 500</code></li>
	<li><code>s</code> consists of lowercase English letters.</li>
</ul>

bool checkPalindrome(string s){
    int size = s.size()-1;
    for(int i = 0 ;i<=size;i++){
        if(i >= (size-i)) return true; 
        if(s[i]!=s[size-i]) return false;
        else continue;
    }
    return true;
}
int getMinPalin(string& s,int F,int L,vector<vector<int>>& dp){
    if(F>=L) return 0;
    //cout<<F<<"  "<<L<<endl;
    int case1 = 0;
    int case2 = 0;
            if(dp[F][L]!=-1) return dp[F][L];
             if(s[F]==s[L]) case1 = getMinPalin(s,F+1,L-1,dp);
    // string k = s.substr(F,L-F+1);
    // if(checkPalindrome(k)) return 0; 
    if(s[F]!=s[L]) case1 = 1+min(getMinPalin(s,F+1,L,dp),getMinPalin(s,F,L-1,dp));
  
    return dp[F][L] = case1;
    //return case1;

}
class Solution {
public:
    int minInsertions(string s) {
        if(checkPalindrome(s)) return 0;
        int size = s.size();
        vector<vector<int>> dp(size+1,vector<int> (size+1,-1));
return getMinPalin(s,0,size-1,dp);

    }
};
25200