Minimum ASCII Delete Sum for Two Strings

Given two strings s1 and s2, return the lowest ASCII sum of deleted characters to make the two strings equal.

Example 1
Inputs1 = "sea", s2 = "eat"
Output231
Deleting s from sea adds 115 and deleting t from eat adds 116, for a minimum total of 231.
Example 2
Inputs1 = "delete", s2 = "leet"
Output403
Deleting dee from delete and e from leet makes both strings equal to let with total cost 403, which is minimal.

Constraints

  • 1 <= s1.length, s2.length <= 1000
  • s1 and s2 consist of lowercase English letters.

Asked at 4 companies

</>

Your Solution

(Ctrl/Cmd + Enter)

Switching Language

Loading template...

Loading...

Sign in to save your progress

AI code evaluation

Get a correctness verdict, missed edge cases, and complexity analysis of your solution.

Sign in to evaluate