摘要: 题目链接 23. 合并K个升序链表 思路 把全部结点放入优先队列中,然后再依次组成新链表 代码 class Solution { public ListNode mergeKLists(ListNode[] lists) { PriorityQueue<Integer> listNodePriori 阅读全文
posted @ 2023-01-08 14:37 Frodo1124 阅读(21) 评论(0) 推荐(0) 编辑
摘要: 题目链接 347. 前 K 个高频元素 思路 前k大模板题 代码 class Solution{ public int[] topKFrequent(int[] nums, int k){ PriorityQueue<Map.Entry<Integer, Integer>> priorityQueu 阅读全文
posted @ 2023-01-08 11:46 Frodo1124 阅读(11) 评论(0) 推荐(0) 编辑
摘要: 题目链接 973. 最接近原点的 K 个点 思路 使用优先队列处理前k大问题 代码 class Solution { class Node{ int x; int y; double distance; } public int[][] kClosest(int[][] points, int k) 阅读全文
posted @ 2023-01-08 11:11 Frodo1124 阅读(31) 评论(0) 推荐(0) 编辑