File tree Expand file tree Collapse file tree 1 file changed +1
-15
lines changed
src/main/java/com/fishercoder/solutions Expand file tree Collapse file tree 1 file changed +1
-15
lines changed Original file line number Diff line number Diff line change 1
1
package com .fishercoder .solutions ;
2
2
3
- /**
4
- * 72. Edit Distance
5
- *
6
- * Given two words word1 and word2,
7
- * find the minimum number of steps required to convert word1 to word2.
8
- * (each operation is counted as 1 step.)
9
-
10
- You have the following 3 operations permitted on a word:
11
-
12
- a) Insert a character
13
- b) Delete a character
14
- c) Replace a character
15
- */
16
-
17
3
public class _72 {
18
4
19
5
public static class Solution1 {
@@ -43,7 +29,7 @@ public int minDistance(String word1, String word2) {
43
29
cost = 1 ;
44
30
}
45
31
table [i ][j ] = Math .min (Math .min (table [i - 1 ][j ] + 1 , table [i ][j - 1 ] + 1 ),
46
- table [i - 1 ][j - 1 ] + cost );
32
+ table [i - 1 ][j - 1 ] + cost );
47
33
}
48
34
}
49
35
return table [m ][n ];
You can’t perform that action at this time.
0 commit comments