Delete characters from two strings so the remaining common subsequence has the minimum total ASCII deletion cost.
Given two strings s1 and s2, you may delete characters from either string. Each deleted character adds its ASCII value to the total cost.
Return the minimum possible total ASCII deletion sum needed to make the two strings equal.
Two strings are considered equal if they become exactly the same after deletions.
s1 and s2.0 <= s1.length, s2.length <= 1000s1: first strings2: second strings1 and s2 equal.0 <= |s1|, |s2| <= 1000Example 1
Input
s1 = "sea", s2 = "eat"
Output
231
Explanation
Delete 's' from "sea" and 't' from "eat". The cost is 115 + 116 = 231.
Example 2
Input
s1 = "delete", s2 = "leet"
Output
403
Explanation
One optimal way is to delete 'd' and 'e' from the first string and 'l' from the second string, among other equivalent optimal choices, for a total cost of 403.
Premium problem context
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.