1168. Minimum ASCII Delete Sum for Two Strings

EasyDynamic ProgrammingSequence DP

Given two strings a and b, return the lowest possible sum of ASCII values of characters deleted from the two strings to make them equal. The input is JSON {a, b}.

Input: JSON {a, b}.

Output: Integer — the minimum ASCII delete sum.

Examples

Example 1
Input: {"a":"sea","b":"eat"}
Output: 231
Explanation: Delete 's' (115) and 't' (116).
Example 2
Input: {"a":"delete","b":"leet"}
Output: 403
Explanation: Optimal deletions sum to 403.
Example 3
Input: {"a":"a","b":"a"}
Output: 0
Explanation: Already equal.

Constraints

Asked by

GoogleMeta
Solve this problem in the editor →