140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
|
matrix[i-1][j-1] + nCost // Substitution
);
if (i > 1 && j > 1 && s1[i] == s2[j-1] && s1[i-1] == s2[j]) {
matrix[i][j] = Math.min(matrix[i][j], matrix[i-2][j-2] + nCost); // Transposition
}
}
}
return Math.floor(matrix[nLen1][nLen2]);
}
catch (e) {
console.error(e);
}
},
showDistance (s1, s2) {
|
|
|
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
|
matrix[i-1][j-1] + nCost // Substitution
);
if (i > 1 && j > 1 && s1[i] == s2[j-1] && s1[i-1] == s2[j]) {
matrix[i][j] = Math.min(matrix[i][j], matrix[i-2][j-2] + nCost); // Transposition
}
}
}
return matrix[nLen1][nLen2];
}
catch (e) {
console.error(e);
}
},
showDistance (s1, s2) {
|