You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<h2>712. Minimum ASCII Delete Sum for Two Strings</h2><h3>Medium</h3><hr><div><p>Given two strings <code>s1, s2</code>, find the lowest ASCII sum of deleted characters to make two strings equal.</p>
2
+
3
+
<p><b>Example 1:</b><br>
4
+
</p><pre><b>Input:</b> s1 = "sea", s2 = "eat"
5
+
<b>Output:</b> 231
6
+
<b>Explanation:</b> Deleting "s" from "sea" adds the ASCII value of "s" (115) to the sum.
7
+
Deleting "t" from "eat" adds 116 to the sum.
8
+
At the end, both strings are equal, and 115 + 116 = 231 is the minimum sum possible to achieve this.
9
+
</pre>
10
+
<p></p>
11
+
12
+
<p><b>Example 2:</b><br>
13
+
</p><pre><b>Input:</b> s1 = "delete", s2 = "leet"
14
+
<b>Output:</b> 403
15
+
<b>Explanation:</b> Deleting "dee" from "delete" to turn the string into "let",
16
+
adds 100[d]+101[e]+101[e] to the sum. Deleting "e" from "leet" adds 101[e] to the sum.
17
+
At the end, both strings are equal to "let", and the answer is 100+101+101+101 = 403.
18
+
If instead we turned both strings into "lee" or "eet", we would get answers of 433 or 417, which are higher.
0 commit comments