Dynamic Programming21 sections · 916 units
Open in Course

LeetCode 583 Delete Operation for Two Strings - Problem Statement

LeetCode 583

Solve Delete Operation for Two Strings from LeetCode. Given two strings word1word1 and word2word2, find the minimum number of deletions to make them equal. You can only delete characters, not insert or replace.

This connects directly to LCS. If LCS has length LL, you need to delete mLm - L characters from word1word1 and nLn - L from word2word2. Total deletions: m+n2Lm + n - 2L.