Description
Given two strings, return minimum number of steps to make them equal. Each step can delete one character from either string.
Examples
Input:
word1 = "sea", word2 = "eat"Output:
2Explanation:
Delete 's' from 'sea' and 't' from 'eat'.
Input:
word1 = "a", word2 = "a"Output:
0Explanation:
Edge case with a single character.
Input:
word1 = "leetcode", word2 = "etco"Output:
4Explanation:
The longest common subsequence is "etco" with length 4. The task requires delete 4 characters from "leetcode" (l, e, d, e) and 0 characters from "etco", totaling 4 deletions to make both strings equal to "etco".
Constraints
- •
1 ≤ word1.length, word2.length ≤ 500