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.
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.
Example 1:
Input: {"word1":"sea","word2":"eat"}
Output: 2
Constraints:
1≤word1.length,word2.length≤500
word1 and word2 consist of only lowercase English letters.
Test Cases
Input (Stdin)
Expected Output (Stdout)
Execution Result
Run code to see results.
Input
arr ={"word1":"sea","word2":"eat"}
Build an (4) x (4) table: dp[i][j] = fewest deletions to make the first i letters of word1 equal the first j letters of word2.