Skip to content

Commit c2d8c12

Browse files
committedNov 4, 2019
fix: remove will return and remove the element from the heap
1 parent 1e2a548 commit c2d8c12

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed
 

‎src/_DataStructures_/Heaps/k-largest-in-array/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ function findKLargest(collection, k) {
1414
const result = [];
1515

1616
for (let i = 0; i < k; i += 1) {
17-
result.push(mh.getMax());
17+
result.push(mh.remove());
1818
}
1919
return result;
2020
}

‎src/_DataStructures_/Heaps/k-smallest-in-array/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ function findKSmallest(collection, k) {
1313
const mh = new MinHeap(collection);
1414
const result = [];
1515
for (let i = 0; i < k; i += 1) {
16-
result.push(mh.getMin());
16+
result.push(mh.remove());
1717
}
1818
return result;
1919
}

0 commit comments

Comments
 (0)
Please sign in to comment.