mirror of
https://github.com/krahets/hello-algo.git
synced 2025-11-03 05:27:55 +08:00
Several bug fixes.
This commit is contained in:
@ -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])
|
||||
|
||||
Reference in New Issue
Block a user