【Leetcode】Edit Distance
来源:互联网 发布:淘宝一键铺货软件 编辑:程序博客网 时间:2024/05/12 21:09
题目链接: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
思路:
c[i][j]表示word1的0~i子串和word2的0~j子串的最小编辑距离。状态转移方程:
如果sc[i]==tc[j]即最后一个字符相等 : c[i][j]=min{c[i-1][j],c[i][j-1],c[i-1][j-1]}
否则最后一个字符需要替换增加1个编辑距离:c[i][j]=min{c[i-1][j],c[i][j-1],c[i-1][j-1]+1}
算法:
1 0
- LeetCode: Edit Distance
- LeetCode Edit Distance
- LeetCode: Edit Distance
- [Leetcode] Edit Distance
- leetcode 19: Edit Distance
- [LeetCode] Edit Distance
- [Leetcode] Edit Distance
- LeetCode Edit Distance
- [LeetCode] Edit Distance
- [LeetCode]Edit Distance
- Leetcode: Edit Distance
- [leetcode]Edit Distance
- LeetCode-Edit Distance
- [leetcode] Edit Distance
- LeetCode - Edit Distance
- leetcode之Edit Distance
- leetcode edit distance
- 【leetcode】Edit Distance
- 安卓实战中防止Button的频繁点击多次执行点击事件和点击切换文字
- zoj3203题解
- UVA 11882Biggest Number
- JSTL常用标签的使用
- vs2010中文旗舰版,vs2013,vs2015企业版激活秘钥
- 【Leetcode】Edit Distance
- Linux下tomcat初级
- web前端性能优化总结
- Maven入门
- 使用 SimpleAdapter 显示listview
- 2016"百度之星" - 初赛(Astar Round2A)Sitting in Line(★)
- 【Leetcode】Longest Increasing Subsequence
- Program3_V
- Codeforces Round #353 (Div. 2) A B C D map迭代器