标签:int else style 字符串 width lse info solution ndis
题目:
解答:
1 class Solution { 2 public: 3 int minDistance(string word1, string word2) 4 { 5 int N1 = word1.size(); 6 int N2 = word2.size(); 7 8 vector<vector<int> > dp(N1 + 1, vector<int>(N2 + 1)); 9 10 for (int i = 1; i <= N1; ++i) 11 { 12 for (int j = 1; j <= N2; ++j) 13 { 14 if (word1[i - 1] == word2[j - 1]) 15 { 16 dp[i][j] = 1 + dp[i - 1][j - 1]; 17 } 18 else 19 { 20 dp[i][j] = max(dp[i][j - 1], dp[i - 1][j]); 21 } 22 } 23 } 24 return N1 + N2 - 2 * dp[N1][N2]; 25 } 26 };
标签:int else style 字符串 width lse info solution ndis
原文地址:https://www.cnblogs.com/ocpc/p/12826112.html