File tree 1 file changed +8
-8
lines changed
src/main/java/com/fishercoder/solutions
1 file changed +8
-8
lines changed Original file line number Diff line number Diff line change @@ -28,22 +28,22 @@ public class _712 {
28
28
public static class Solution1 {
29
29
//credit: https://leetcode.com/articles/minimum-ascii-delete-sum-for-two-strings/
30
30
public int minimumDeleteSum (String s1 , String s2 ) {
31
- int [][] dp = new int [s1 .length ()+ 1 ][s2 .length ()+ 1 ];
31
+ int [][] dp = new int [s1 .length () + 1 ][s2 .length () + 1 ];
32
32
33
- for (int i = s1 .length ()- 1 ; i >= 0 ; i --) {
34
- dp [i ][s2 .length ()] = dp [i + 1 ][s2 .length ()] + s1 .codePointAt (i );
33
+ for (int i = s1 .length () - 1 ; i >= 0 ; i --) {
34
+ dp [i ][s2 .length ()] = dp [i + 1 ][s2 .length ()] + s1 .codePointAt (i );
35
35
}
36
36
37
- for (int j = s2 .length ()- 1 ; j >= 0 ; j --) {
38
- dp [s1 .length ()][j ] = dp [s1 .length ()][j + 1 ] + s2 .codePointAt (j );
37
+ for (int j = s2 .length () - 1 ; j >= 0 ; j --) {
38
+ dp [s1 .length ()][j ] = dp [s1 .length ()][j + 1 ] + s2 .codePointAt (j );
39
39
}
40
40
41
41
for (int i = s1 .length () - 1 ; i >= 0 ; i --) {
42
- for (int j = s2 .length ()- 1 ; j >= 0 ; j --) {
42
+ for (int j = s2 .length () - 1 ; j >= 0 ; j --) {
43
43
if (s1 .charAt (i ) == s2 .charAt (j )) {
44
- dp [i ][j ] = dp [i + 1 ][j + 1 ];
44
+ dp [i ][j ] = dp [i + 1 ][j + 1 ];
45
45
} else {
46
- dp [i ][j ] = Math .min (dp [i + 1 ][j ] + s1 .codePointAt (i ), dp [i ][j + 1 ] + s2 .codePointAt (j ));
46
+ dp [i ][j ] = Math .min (dp [i + 1 ][j ] + s1 .codePointAt (i ), dp [i ][j + 1 ] + s2 .codePointAt (j ));
47
47
}
48
48
}
49
49
}
You can’t perform that action at this time.
0 commit comments