A DP classic that screens for one thing: can you define the right subproblem and fill the table without fumbling the indices. The strong version adds the O(min(m,n)) space trick and reconstructs the actual edits when the follow-up lands.
← Coding & DSA / 73
hard★ EssentialGoogleMetaAdobe
Compute the edit distance (Levenshtein) between two strings.
A DP classic that screens for one thing: can you define the right subproblem and fill the table without fumbling the indices. The strong version adds the O(min(m,n)) space trick and reconstructs the actual edits when the follow-up lands.
Updated Aug 2026 · Grounded in real Forward Deployed Engineer interview loops and written to a senior-engineer editorial bar.
Unlock the other 466 answers · ₹2,000 / $25Your progress and mastery stay saved · 6 months · one payment · no auto-renew
UP NEXT ON YOUR JOURNEY
FEDITOR'S NOTE
The state is the whole question. If you can say 'dp[i][j] is the distance between the first i chars of a and the first j chars of b' and then justify the three transitions, you pass. Candidates who jump to code without naming the state almost always botch the base row or the off-by-one in the loop bounds.
DISCUSSION · 0
No comments yet — be the first to share your approach.
