Skip to content

Practice Delete Operation for Two Strings

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Medium#583
LeetCode Problem

Delete Operation for Two Strings

Problem Statement

Given two strings word1 and word2, return the minimum number of steps required to make word1 and word2 the same. In one step, you can delete exactly one character in either string.

Source: Delete Operation for Two Strings on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
word1 = "sea", word2 = "eat"
Output
2

# Example 2

Input
word1 = "leetcode", word2 = "etco"
Output
4

Constraints

1 <= word1.length, word2.length <= 500
word1 and word2 consist of only lowercase English letters.

Related LeetCode Problems

Practice more problems similar to Delete Operation for Two Strings.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.