mirror of
https://github.com/krahets/hello-algo.git
synced 2025-11-02 04:31:55 +08:00
fix: compiler error and reset root (#570)
This commit is contained in:
@ -123,7 +123,7 @@ class BinarySearchTree {
|
||||
// 当子节点数量 = 0 / 1 时, child = null / 该子节点
|
||||
let child = cur?.left != nil ? cur?.left : cur?.right
|
||||
// 删除节点 cur
|
||||
if cur != root {
|
||||
if cur !== root {
|
||||
if pre?.left === cur {
|
||||
pre?.left = child
|
||||
} else {
|
||||
@ -131,7 +131,7 @@ class BinarySearchTree {
|
||||
}
|
||||
} else {
|
||||
// 若删除节点为根节点,则重新指定根节点
|
||||
root = cur;
|
||||
root = child
|
||||
}
|
||||
}
|
||||
// 子节点数量 = 2
|
||||
|
||||
Reference in New Issue
Block a user