1. Problem Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each operation is counted as 1 step.) You have the following 3 operations permitted on a word: a) Insert a character b) Delete a character c) Replace a character 2. Idea Every time an optimal solution is required, you should remind yourself of the opportunity to apply dynamic programming, which is the case for my solution. Denote by the minimum distance between word1[i...m-1] and word2[j...n-1] ( where and are the length of word1 and word2, respectively. Both word1[m...
Read full article from LeetCode - Edit Distance | Darren's Blog
No comments:
Post a Comment