mirror of
https://github.com/krahets/hello-algo.git
synced 2026-07-26 21:16:07 +00:00
feat(go): add iterration/recursion & fix bugs (#698)
This commit is contained in:
@@ -28,7 +28,7 @@ maxHeap *newMaxHeap(int nums[], int size) {
|
||||
maxHeap *h = (maxHeap *)malloc(sizeof(maxHeap));
|
||||
h->size = size;
|
||||
memcpy(h->data, nums, size * sizeof(int));
|
||||
for (int i = size - 1; i >= 0; i--) {
|
||||
for (int i = parent(size - 1); i >= 0; i--) {
|
||||
// 堆化除叶节点以外的其他所有节点
|
||||
siftDown(h, i);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user