22 - Edit Distance - Dynamic Programming approach

@Rishi Srivastava Pseudo code: - If the last character of “word1“ equals the last character of “word2“, then EditDistance(word1[0:m-1],word2[0:n-1]) = EditDistance(word1[0:m-2],word2[0:n-2]) - Else if the last character of “word1“ DO NOT match the last character of “word2“, then EditDistance(word1[0:m-1],word2[0:n-1]) = 1 MIN(EditDistance(word1[0:m-2],word2[0:n-2]), EditDistance(word1[0:m-1],word2[0:n-2]), EditDistance(word1[0:m-2],word2[0:n-1])) Github: Leetcode:
Back to Top