15% off all plans & roadmaps Use code
See plansLeetCode 712 · Solution & editorial
Given two strings s1, s2, find the lowest ASCII sum of deleted characters to make two strings equal.
Minimum ASCII Delete Sum for Two Strings is a Dynamic Programming (DP) Patterns problem, in the 2D Array (Edit Distance / Levenshtein Distance) subpattern. The pattern covers fibonacci, Kadane, knapsack, LCS, LIS, edit distance, grid paths, and word break
Calculate minimum edit operations to transform one string to another using 2D DP.
The reference solution runs in O(m * n) time and O(n) space.
Minimum ASCII Delete Sum for Two Strings has been reported in interviews at TripleByte.
The full editorial is part of Pro
It explains the core insight, the complexity analysis and the common mistakes, with a worked solution.
Minimum ASCII Delete Sum for Two Strings is a Dynamic Programming (DP) Patterns problem, in the 2D Array (Edit Distance / Levenshtein Distance) subpattern. Once the approach above makes sense, write it yourself and then work through the neighbouring problems that reuse it.