Edit Distance

From: https://leetcode.com/problems/edit-distance/

题目:

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

分析:

该题目与 Distinct Subsequences 的思路基本是一致的,都是二维 DP 求解。DP 问题需要专门再深入学习理解。

比较简单的思路是 Brute Force,类似 Backtracking。但是复杂度会是 O(n3).

Reference:

Code Ganker Solution: http://blog.csdn.net/linhuanmars/article/details/24213795

原文地址:https://www.cnblogs.com/Phoenix-Fearless/p/5099985.html