mirror of
https://github.com/krahets/hello-algo.git
synced 2025-11-02 21:24:53 +08:00
Add JavaScript and TypeScript code of top_k and update some code style (#686)
* Update JS and TS code style * Add JavaScript and TypeScript code of top_k * Update top_k.ts * Apply suggestions from code review Co-authored-by: Justin Tse <xiefahit@gmail.com> * Apply suggestions from code review Co-authored-by: Justin Tse <xiefahit@gmail.com> --------- Co-authored-by: Yudong Jin <krahets@163.com>
This commit is contained in:
@ -115,6 +115,11 @@ class MaxHeap {
|
||||
print() {
|
||||
printHeap(this.#maxHeap);
|
||||
}
|
||||
|
||||
/* 取出堆中元素 */
|
||||
getMaxHeap() {
|
||||
return this.#maxHeap;
|
||||
}
|
||||
}
|
||||
|
||||
/* Driver Code */
|
||||
@ -145,3 +150,8 @@ console.log(`\n堆元素数量为 ${size}`);
|
||||
/* 判断堆是否为空 */
|
||||
let isEmpty = maxHeap.isEmpty();
|
||||
console.log(`\n堆是否为空 ${isEmpty}`);
|
||||
|
||||
|
||||
module.exports = {
|
||||
MaxHeap,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user