#include <leetcode.h>
◆ minDistance()
int leetcode::edit_distance::Solution::minDistance |
( |
string |
word1, |
|
|
string |
word2 |
|
) |
| |
|
static |
在文件 leetcode.cpp 第 6781 行定义.
6783 vector dp(word1.length() + 1, vector<int>(word2.length() + 1));
6785 for(
int j = 0; j <= word2.length(); j++) {
6788 for(
int i = 0; i <= word1.length(); i++) {
6791 for(
int i = 1; i <= word1.length(); i++) {
6792 for(
int j = 1; j <= word2.length(); j++) {
6793 if(word1[i - 1] == word2[j - 1]) {
6794 dp[i][j] = dp[i - 1][j - 1];
6796 dp[i][j] = min(min(dp[i - 1][j], dp[i][j - 1]), dp[i - 1][j - 1]) + 1;
6800 return dp.back().back();
被这些函数引用 leetcode::edit_distance::TEST().
该类的文档由以下文件生成: