#583
Delete Operation for Two Strings
specialist · 625 · lc medium +29 · verified · 65.3% accepted · 6,147 likes · top 70%
Description
Given two strings word1 and word2, return the fewest total character deletions (one deletion per step, applied to either string) needed to make the two strings identical.
Example 1:
Input: word1 = "sea", word2 = "eat"
Output: 2
Explanation: You need one step to make "sea" to "ea" and another step to make "eat" to "ea".
Example 2:
Input: word1 = "leetcode", word2 = "etco"
Output: 4
Code
1
2
3