<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>

class Solution {
public:
int longestCommonSubsequence(string text1, string text2) {
        vector<vector<int>> dp(text1.size(), vector<int>(text2.size(),-1));
        // return solve(text1,text2,dp,0,0);
        int i,j;
        for(i=0;i<text1.size();i++)
        {
            for(j=0;j<text2.size();j++)
            {
                if(text1[i]==text2[j])
                {
                    if(i==0 || j==0)
                    dp[i][j]=1;
                    else
                    dp[i][j]=dp[i-1][j-1]+1;
                }
                else
                {
                    if(i!=0 && j!=0)
                    dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
                    else if(j!=0)
                    dp[i][j]=dp[i][j-1];
                    else if(i!=0)
                    dp[i][j]=dp[i-1][j];
                    else
                    dp[i][j]=0;
                }
            }
        }
        // for(auto x:dp)
        // {
        //     cout<<endl;
        //     for(auto y:x)
        //     cout<<y<<" ";
        // }
        return dp[text1.size()-1][text2.size()-1];
    }
    int minInsertions(string s) {
        string rev="";
        int i;
        for(i=0;i<s.size();i++)
        {
            rev = s[i] +rev;
        }
        if(rev==s)
        return 0;
        cout<<s.substr(0,(s.size())/2)<<" "<<s.substr((s.size())/2);
        int l = longestCommonSubsequence(s, rev);
        // if(s.size()%2==0)
        // return s.size() - 2*l;
        // else
        return s.size() - l;
    }
};
29200