From b36f6755998b4ed3ca3e827e547bca95dce224da Mon Sep 17 00:00:00 2001 From: Dewittt <43514251+Dewittt@users.noreply.github.com> Date: Mon, 3 Jan 2022 15:56:46 +0800 Subject: [PATCH] =?UTF-8?q?Update=200347.=E5=89=8DK=E4=B8=AA=E9=AB=98?= =?UTF-8?q?=E9=A2=91=E5=85=83=E7=B4=A0.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 前k个,应该传入倒序的comparator --- problems/0347.前K个高频元素.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/problems/0347.前K个高频元素.md b/problems/0347.前K个高频元素.md index e6ad751b..a2825573 100644 --- a/problems/0347.前K个高频元素.md +++ b/problems/0347.前K个高频元素.md @@ -142,7 +142,7 @@ class Solution { Set> entries = map.entrySet(); // 根据map的value值正序排,相当于一个小顶堆 - PriorityQueue> queue = new PriorityQueue<>((o1, o2) -> o1.getValue() - o2.getValue()); + PriorityQueue> queue = new PriorityQueue<>((o1, o2) -> o2.getValue() - o1.getValue()); for (Map.Entry entry : entries) { queue.offer(entry); if (queue.size() > k) {