Format code with prettier (#3375)

This commit is contained in:
acbin
2022-10-03 17:23:00 +08:00
committed by GitHub
parent 32b9b11ed5
commit e96f567bfc
464 changed files with 11483 additions and 6189 deletions

View File

@ -77,7 +77,13 @@ public class EditDistance {
// ans stores the final Edit Distance between the two strings
int ans = minDistance(s1, s2);
System.out.println(
"The minimum Edit Distance between \"" + s1 + "\" and \"" + s2 + "\" is " + ans);
"The minimum Edit Distance between \"" +
s1 +
"\" and \"" +
s2 +
"\" is " +
ans
);
input.close();
}
@ -85,7 +91,6 @@ public class EditDistance {
public static int editDistance(String s1, String s2) {
int[][] storage = new int[s1.length() + 1][s2.length() + 1];
return editDistance(s1, s2, storage);
}
public static int editDistance(String s1, String s2, int[][] storage) {
@ -93,22 +98,19 @@ public class EditDistance {
int n = s2.length();
if (storage[m][n] > 0) {
return storage[m][n];
}
if (m == 0) {
storage[m][n] = n;
return storage[m][n];
}
if (n == 0) {
storage[m][n] = m;
return storage[m][n];
}
if (s1.charAt(0) == s2.charAt(0)) {
storage[m][n] = editDistance(s1.substring(1), s2.substring(1), storage);
storage[m][n] =
editDistance(s1.substring(1), s2.substring(1), storage);
return storage[m][n];
} else {
int op1 = editDistance(s1, s2.substring(1), storage);
int op2 = editDistance(s1.substring(1), s2, storage);