<p>Given two strings <code>s1</code> and&nbsp;<code>s2</code>, return <em>the lowest <strong>ASCII</strong> sum of deleted characters to make two strings equal</em>.</p>

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

<pre>
<strong>Input:</strong> s1 = &quot;sea&quot;, s2 = &quot;eat&quot;
<strong>Output:</strong> 231
<strong>Explanation:</strong> Deleting &quot;s&quot; from &quot;sea&quot; adds the ASCII value of &quot;s&quot; (115) to the sum.
Deleting &quot;t&quot; from &quot;eat&quot; adds 116 to the sum.
At the end, both strings are equal, and 115 + 116 = 231 is the minimum sum possible to achieve this.
</pre>

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

<pre>
<strong>Input:</strong> s1 = &quot;delete&quot;, s2 = &quot;leet&quot;
<strong>Output:</strong> 403
<strong>Explanation:</strong> Deleting &quot;dee&quot; from &quot;delete&quot; to turn the string into &quot;let&quot;,
adds 100[d] + 101[e] + 101[e] to the sum.
Deleting &quot;e&quot; from &quot;leet&quot; adds 101[e] to the sum.
At the end, both strings are equal to &quot;let&quot;, and the answer is 100+101+101+101 = 403.
If instead we turned both strings into &quot;lee&quot; or &quot;eet&quot;, we would get answers of 433 or 417, which are higher.
</pre>

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

<ul>
	<li><code>1 &lt;= s1.length, s2.length &lt;= 1000</code></li>
	<li><code>s1</code> and <code>s2</code> consist of lowercase English letters.</li>
</ul>

#define ll long long int
const ll lim =  1e3 + 3;
ll dp[lim][lim];
string s1,s2;
ll n1,n2;

ll solve(ll i, ll j)
{
    if(i==n1 || j==n2) return 0;
    
    if(dp[i][j] != -1) return dp[i][j];
    
    ll ret=0;
    
    if(s1[i]==s2[j])
    {
        ret = (ll)s1[i] + solve(i+1, j+1);
    }
    else
    {
        ret = max( solve(i+1, j), solve(i,j+1) );
    }
    
    return dp[i][j] = ret;
}

ll asciiSum(string str)
{
    ll sum=0,i,n;
    n = str.size();
    
    for(i=0; i<n; i++)
    {
        sum = sum + (ll)(str[i]);
    }
    return sum;
}

class Solution {
public:
    int minimumDeleteSum(string str1, string str2) {
        
        n1 = str1.size();
        n2 = str2.size();
        
        s1 = str1;
        s2 = str2;
        
        ll i,j;
        
//         for(i=0; i<=n1; i++)
//         {
//             for(j=0; j<=n2; j++)
//             {
                
//             }
//         }
        memset(dp,-1,sizeof(dp));
        
        ll MaxSum,s1sum,s2sum,ans=1;
        
        MaxSum = solve(0,0);
        s1sum  = asciiSum(str1);
        s2sum  = asciiSum(str2);
        
        ans = (s1sum-MaxSum) + (s2sum-MaxSum);
        
        
        return ans;
    }
};
16000