mirror of
https://github.com/krahets/hello-algo.git
synced 2024-12-24 10:16:28 +08:00
Several bug fixes.
This commit is contained in:
parent
53d91db10d
commit
8effa58a59
7 changed files with 6 additions and 9 deletions
|
@ -47,7 +47,6 @@ class MaxHeap {
|
|||
while (true) {
|
||||
// 判断节点 i, l, r 中值最大的节点,记为 ma
|
||||
int l = left(i), r = right(i), ma = i;
|
||||
// 若节点 i 最大或索引 l, r 越界,则无须继续堆化,跳出
|
||||
if (l < size() && maxHeap[l] > maxHeap[ma])
|
||||
ma = l;
|
||||
if (r < size() && maxHeap[r] > maxHeap[ma])
|
||||
|
|
|
@ -83,7 +83,6 @@ class ArrayHashMap {
|
|||
print() {
|
||||
let pairSet = this.entries();
|
||||
for (const pair of pairSet) {
|
||||
if (!pair) continue;
|
||||
console.info(`${pair.key} -> ${pair.val}`);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -87,7 +87,6 @@ class ArrayHashMap {
|
|||
public print() {
|
||||
let pairSet = this.entries();
|
||||
for (const pair of pairSet) {
|
||||
if (!pair) continue;
|
||||
console.info(`${pair.key} -> ${pair.val}`);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
class ListNode:
|
||||
"""链表节点类"""
|
||||
def __init__(self, val: int):
|
||||
self.val: int = val # 节点值
|
||||
self.val: int = val # 节点值
|
||||
self.next: ListNode | None = None # 指向下一节点的引用
|
||||
```
|
||||
|
||||
|
@ -739,7 +739,7 @@
|
|||
class ListNode:
|
||||
"""双向链表节点类"""
|
||||
def __init__(self, val: int):
|
||||
self.val: int = val # 节点值
|
||||
self.val: int = val # 节点值
|
||||
self.next: ListNode | None = None # 指向后继节点的引用
|
||||
self.prev: ListNode | None = None # 指向前驱节点的引用
|
||||
```
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
class Node:
|
||||
"""类"""
|
||||
def __init__(self, x: int):
|
||||
self.val: int = x # 节点值
|
||||
self.val: int = x # 节点值
|
||||
self.next: Node | None = None # 指向下一节点的引用
|
||||
|
||||
def function() -> int:
|
||||
|
|
|
@ -26,8 +26,8 @@ AVL 树既是二叉搜索树也是平衡二叉树,同时满足这两类二叉
|
|||
class TreeNode:
|
||||
"""AVL 树节点类"""
|
||||
def __init__(self, val: int):
|
||||
self.val: int = val # 节点值
|
||||
self.height: int = 0 # 节点高度
|
||||
self.val: int = val # 节点值
|
||||
self.height: int = 0 # 节点高度
|
||||
self.left: TreeNode | None = None # 左子节点引用
|
||||
self.right: TreeNode | None = None # 右子节点引用
|
||||
```
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
class TreeNode:
|
||||
"""二叉树节点类"""
|
||||
def __init__(self, val: int):
|
||||
self.val: int = val # 节点值
|
||||
self.val: int = val # 节点值
|
||||
self.left: TreeNode | None = None # 左子节点引用
|
||||
self.right: TreeNode | None = None # 右子节点引用
|
||||
```
|
||||
|
|
Loading…
Reference in a new issue