Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit c2d8c12

Browse files
committed
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
  • src/_DataStructures_/Heaps

2 files changed

+2
-2
lines changed

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

Lines changed: 1 addition & 1 deletion
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‎

Lines changed: 1 addition & 1 deletion
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)

AltStyle によって変換されたページ (->オリジナル) /