2021-06-21から1日間の記事一覧
class PriorityQueue { constructor(comp) { this.heap = []; this.compare = comp; } isEmpty() { return this.heap.length == 0; } push(x) { this._upHeap(this.heap.push(x) - 1); } pop() { if(this.isEmpty()) { return undefined; } this._heapSwap(0…