From 117bf1079fa786723b13fc3ea5f7b12e1f717142 Mon Sep 17 00:00:00 2001 From: Jayden12138 <18993882884@163.com> Date: Tue, 23 Apr 2024 16:24:02 +0800 Subject: [PATCH] fix(javascript): vvXgSW --- .../solution_code.md" | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git "a/\345\244\232\350\257\255\350\250\200\350\247\243\346\263\225\344\273\243\347\240\201/solution_code.md" "b/\345\244\232\350\257\255\350\250\200\350\247\243\346\263\225\344\273\243\347\240\201/solution_code.md" index 4a577d5958..16fd4de1ac 100644 --- "a/\345\244\232\350\257\255\350\250\200\350\247\243\346\263\225\344\273\243\347\240\201/solution_code.md" +++ "b/\345\244\232\350\257\255\350\250\200\350\247\243\346\263\225\344\273\243\347\240\201/solution_code.md" @@ -67158,20 +67158,21 @@ var mergeKLists = function(lists) { var dummy = new ListNode(-1); var p = dummy; // 优先级队列,最小堆 - var pq = new PriorityQueue( - lists.length, (a, b) => (a.val - b.val)); + var pq = new PriorityQueue({ + compare: (a, b) => (a.val - b.val) + }); // 将 k 个链表的头结点加入最小堆 for (var head of lists) { if (head != null) - pq.add(head); + pq.enqueue(head); } while (!pq.isEmpty()) { // 获取最小节点,接到结果链表中 - var node = pq.poll(); + var node = pq.dequeue(); p.next = node; if (node.next != null) { - pq.add(node.next); + pq.enqueue(node.next); } // p 指针不断前进 p = p.next;