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

class Solution:
    # Adapted from longestCommonSubsequence
    def longestCommonSubsequenceAscii(self, text1: str, text2: str) -> str:
        m, n = len(text1), len(text2)
        dp = [[0] * n for _ in range(m)]

        dp[0][0] = ord(text1[0]) if text1[0] == text2[0] else 0
        for i in range(1, m):
            dp[i][0] = ord(text2[0]) if text1[i] == text2[0] else dp[i-1][0]

        for j in range(1, n):
            dp[0][j] = ord(text1[0])  if text1[0] == text2[j] else dp[0][j-1]
        
        for i in range(1,m):
            for j in range(1,n):
                dp[i][j] = max(dp[i-1][j-1] + (ord(text1[i]) if text1[i] == text2[j] else 0), dp[i][j-1], dp[i-1][j])
        return dp[m-1][n-1]

    # Utilizes longestCommonSubsequence (DP, O(MN) space and time)
    def minimumDeleteSum(self, s1: str, s2: str) -> int:
        m, n = len(s1), len(s2)
        asciiSum = lambda lst: sum(map(lambda ch: ord(ch), lst))
        return asciiSum(s1) + asciiSum(s2) - 2 * self.longestCommonSubsequenceAscii(s1, s2)

        # dp = [[0] * n for _ in range(m)]

        # hasChar = s1[0] == s2[0]
        # if not hasChar: 
        #     dp[0][0] = ord(s1[0]) + ord(s2[0])
        # for j in range(1, n):
        #     if s1[i] == s2[j]:
        #         dp[0][j] = dp[0][j-1]
        #     else: 
        #         dp[0][j] = dp[0][j-1] + ord(s2[j])
        
19976