23. 合并K个升序链表 https://leetcode.cn/problems/merge-k-sorted-lists
23. Merge k Sorted Lists https://leetcode.com/problems/merge-k-sorted-lists
373. 查找和最小的K对数字 https://leetcode.cn/problems/find-k-pairs-with-smallest-sums
373. Find K Pairs with Smallest Sums https://leetcode.com/problems/find-k-pairs-with-smallest-sums
378. 有序矩阵中第 K 小的元素 https://leetcode.cn/problems/kth-smallest-element-in-a-sorted-matrix
378. Kth Smallest Element in a Sorted Matrix https://leetcode.com/problems/kth-smallest-element-in-a-sorted-matrix
313. 超级丑数 https://leetcode.cn/problems/super-ugly-number
313. Super Ugly Number https://leetcode.com/problems/super-ugly-number
355. 设计推特 https://leetcode.cn/problems/design-twitter
355. Design Twitter https://leetcode.com/problems/design-twitter
215. 数组中的第K个最大元素 https://leetcode.cn/problems/kth-largest-element-in-an-array
215. Kth Largest Element in an Array https://leetcode.com/problems/kth-largest-element-in-an-array
451. 根据字符出现频率排序 https://leetcode.cn/problems/sort-characters-by-frequency
451. Sort Characters By Frequency https://leetcode.com/problems/sort-characters-by-frequency
703. 数据流中的第 K 大元素 https://leetcode.cn/problems/kth-largest-element-in-a-stream
703. Kth Largest Element in a Stream https://leetcode.com/problems/kth-largest-element-in-a-stream
347. 前 K 个高频元素 https://leetcode.cn/problems/top-k-frequent-elements
347. Top K Frequent Elements https://leetcode.com/problems/top-k-frequent-elements
692. 前K个高频单词 https://leetcode.cn/problems/top-k-frequent-words
692. Top K Frequent Words https://leetcode.com/problems/top-k-frequent-words
1845. 座位预约管理系统 https://leetcode.cn/problems/seat-reservation-manager
1845. Seat Reservation Manager https://leetcode.com/problems/seat-reservation-manager
295. 数据流的中位数 https://leetcode.cn/problems/find-median-from-data-stream
295. Find Median from Data Stream https://leetcode.com/problems/find-median-from-data-stream
870. 优势洗牌 https://leetcode.cn/problems/advantage-shuffle
870. Advantage Shuffle https://leetcode.com/problems/advantage-shuffle
1834. 单线程 CPU https://leetcode.cn/problems/single-threaded-cpu
1834. Single-Threaded CPU https://leetcode.com/problems/single-threaded-cpu
二叉堆的主要应用是优先级队列,而优先级队列的特色是动态排序,插入的元素可以自动维护正确的顺序。当然,二叉搜索树 也可以做到动态排序,但优先级队列提供的接口更简单,实现也更简单。
一般来说,用到优先级队列的题目主要分两类,一类是把多个有序序列合并成一个,另一类是在多个有序序列中寻找第 k
个最大元素这类题,我们分别来看。
类型一,合并有序序列
先来看第一类,类似于合并有序链表这样的题目。
loading...