Dynamic Programming Dynamic Programming Medium

Min Edit Distance

Longest Common Subsequence

1
2
3
4
5
6
7
8
9
10
11
12
13
14
/*
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".

Input: word1 = "Subsequence", word2 = "bqne"
Output: 4
*/
func minSteps(word1 string, word2 string):
    lcs_length = longestCommonSubsequence(word1, word2)
    steps1 = len(word1) - lcs_length
    steps2 = len(word2) - lcs_length
    return steps1 + steps2

🎰