public:
/**
* min edit cost
* @param str1 string字符串 the string
* @param str2 string字符串 the string
* @param ic int整型 insert cost
* @param dc int整型 delete cost
* @param rc int整型 replace cost
* @return int整型
*/
int minEditCost(string str1, string str2, int ic, int dc, int rc) {
int m = str1.size(), n = str2.size();
vector<vector<int>> dp(m + 1, vector<int>(n + 1));
for(int i = 0; i < m + 1; i++) {
dp[i][0] = dc * i;
}
for(int j = 0; j < n + 1; j++) {
dp[0][j] = ic * j;
}
for(int i = 1; i < m + 1; i++) {
for(int j = 1; j < n + 1; j++) {
int d = (str1[i - 1] == str2[j - 1]) ? 0 : rc ;
dp[i][j] = min(dc + dp[i - 1][j], min(ic + dp[i][j - 1], d + dp[i - 1][j - 1]));
}
}
return dp[m][n];
}
};