java.lang.Object
g0701_0800.s0712_minimum_ascii_delete_sum_for_two_strings.Solution

public class Solution extends Object
712 - Minimum ASCII Delete Sum for Two Strings.<p>Medium</p> <p>Given two strings <code>s1</code> and <code>s2</code>, return <em>the lowest <strong>ASCII</strong> sum of deleted characters to make two strings equal</em>.</p> <p><strong>Example 1:</strong></p> <p><strong>Input:</strong> s1 = &ldquo;sea&rdquo;, s2 = &ldquo;eat&rdquo;</p> <p><strong>Output:</strong> 231</p> <p><strong>Explanation:</strong> Deleting &ldquo;s&rdquo; from &ldquo;sea&rdquo; adds the ASCII value of &ldquo;s&rdquo; (115) to the sum. Deleting &ldquo;t&rdquo; from &ldquo;eat&rdquo; adds 116 to the sum. At the end, both strings are equal, and 115 + 116 = 231 is the minimum sum possible to achieve this.</p> <p><strong>Example 2:</strong></p> <p><strong>Input:</strong> s1 = &ldquo;delete&rdquo;, s2 = &ldquo;leet&rdquo;</p> <p><strong>Output:</strong> 403</p> <p><strong>Explanation:</strong> Deleting &ldquo;dee&rdquo; from &ldquo;delete&rdquo; to turn the string into &ldquo;let&rdquo;, adds 100[d] + 101[e] + 101[e] to the sum. Deleting &ldquo;e&rdquo; from &ldquo;leet&rdquo; adds 101[e] to the sum. At the end, both strings are equal to &ldquo;let&rdquo;, and the answer is 100+101+101+101 = 403. If instead we turned both strings into &ldquo;lee&rdquo; or &ldquo;eet&rdquo;, we would get answers of 433 or 417, which are higher.</p> <p><strong>Constraints:</strong></p> <ul> <li><code>1 <= s1.length, s2.length <= 1000</code></li> <li><code>s1</code> and <code>s2</code> consist of lowercase English letters.</li> </ul>
  • Constructor Details

    • Solution

      public Solution()
  • Method Details

    • minimumDeleteSum

      public int minimumDeleteSum(String s1, String s2)