This commit is contained in:
krahets
2024-05-06 14:40:36 +08:00
parent 7e7eb6047a
commit 5c7d2c7f17
54 changed files with 3456 additions and 215 deletions
+9 -1
View File
@@ -42,7 +42,15 @@ It's worth mentioning that **since leaf nodes have no children, they naturally f
=== "C++"
```cpp title="my_heap.cpp"
[class]{MaxHeap}-[func]{MaxHeap}
/* Constructor, build heap based on input list */
MaxHeap(vector<int> nums) {
// Add all list elements into the heap
maxHeap = nums;
// Heapify all nodes except leaves
for (int i = parent(size() - 1); i >= 0; i--) {
siftDown(i);
}
}
```
=== "Java"