This commit is contained in:
krahets
2023-11-17 00:35:19 +08:00
parent c7794e1a84
commit 5ae2d5e925
17 changed files with 229 additions and 178 deletions
+1 -1
View File
@@ -392,7 +392,7 @@ comments: true
int *topKHeap(int *nums, int sizeNums, int k) {
// 初始化小顶堆
// 请注意:我们将堆中所有元素取反,从而用大顶堆来模拟小顶堆
int empty[0];
int *empty = (int *)malloc(0);
MaxHeap *maxHeap = newMaxHeap(empty, 0);
// 将数组的前 k 个元素入堆
for (int i = 0; i < k; i++) {