Format code and docs.

This commit is contained in:
krahets
2023-10-24 16:19:29 +08:00
parent d639d946f0
commit 17252b53a9
11 changed files with 42 additions and 48 deletions
@@ -74,7 +74,8 @@ function editDistanceDP(s, t) {
dp[i][j] = dp[i - 1][j - 1];
} else {
// 最少编辑步数 = 插入、删除、替换这三种操作的最少编辑步数 + 1
dp[i][j] = Math.min(dp[i][j - 1], dp[i - 1][j], dp[i - 1][j - 1]) + 1
dp[i][j] =
Math.min(dp[i][j - 1], dp[i - 1][j], dp[i - 1][j - 1]) + 1;
}
}
}
+2 -10
View File
@@ -184,16 +184,8 @@ if __name__ == "__main__":
# 插入节点
# 请关注插入节点后,AVL 树是如何保持平衡的
test_insert(avl_tree, 1)
test_insert(avl_tree, 2)
test_insert(avl_tree, 3)
test_insert(avl_tree, 4)
test_insert(avl_tree, 5)
test_insert(avl_tree, 8)
test_insert(avl_tree, 7)
test_insert(avl_tree, 9)
test_insert(avl_tree, 10)
test_insert(avl_tree, 6)
for val in [1, 2, 3, 4, 5, 8, 7, 9, 10, 6]:
test_insert(avl_tree, val)
# 插入重复节点
test_insert(avl_tree, 7)
@@ -82,7 +82,8 @@ function editDistanceDP(s: string, t: string): number {
dp[i][j] = dp[i - 1][j - 1];
} else {
// 最少编辑步数 = 插入、删除、替换这三种操作的最少编辑步数 + 1
dp[i][j] = Math.min(dp[i][j - 1], dp[i - 1][j], dp[i - 1][j - 1]) + 1
dp[i][j] =
Math.min(dp[i][j - 1], dp[i - 1][j], dp[i - 1][j - 1]) + 1;
}
}
}