随笔分类 -  PriorityQueue

优先队列
[Leetcode 787]中转K站内最便宜机票
摘要:题目 n个城市,想求从src到dist的最廉价机票 有中转站数K的限制,即如果k=5,中转10次机票1000,中转5次机票2000,最后返回2000 There are n cities connected by some number of flights. You are given an ar 阅读全文
posted @ 2021-11-30 07:23 alau 阅读(71) 评论(0) 推荐(0)
[Leetcode 1631]最少体力消耗的路径Path With Minimum Effort
摘要:题目 https://leetcode.com/problems/path-with-minimum-effort/ 每个节点的height不同,矩阵从左上走到右下,求最小体力消耗 当前点体力消耗:max(来的那个节点的effort,|来的那个节点height-当前节点height|) 总最小体力消 阅读全文
posted @ 2021-11-30 06:12 alau 阅读(70) 评论(0) 推荐(0)
[Leetcode 451]*Sort Characters By Frequency优先队列
摘要:题目 Given a string s, sort it in decreasing order based on the frequency of the characters. The frequency of a character is the number of times it appe 阅读全文
posted @ 2021-11-30 02:17 alau 阅读(376) 评论(0) 推荐(0)
[Leetcode 692/347]前K个高频词Top K Frequent Words Element
摘要:题目347 https://leetcode.com/problems/top-k-frequent-elements/ 347简单些,692是其变式,多了一种排序 Given an integer array nums and an integer k, return the k most fre 阅读全文
posted @ 2021-11-30 01:41 alau 阅读(32) 评论(0) 推荐(0)
[Leetcode 703]流中第K个最大元素Kth Largest Element in a Stream优先队列239
摘要:题目 找到一串数字中的第K大元素 在原数组的基础上,每次会不断插入元素 插入的同时要返回插入后第K大的元素 https://leetcode.com/problems/kth-largest-element-in-a-stream/ Design a class to find the kth la 阅读全文
posted @ 2021-11-29 04:10 alau 阅读(61) 评论(0) 推荐(0)
[Leetcode 23]合并有序列表Merge k Sorted Lists
摘要:太久没刷题自闭了爬上来记录下 【题目】 将K个顺序排列的列表合并,输出合并后的列表 Example 1: Input: lists = [[1,4,5],[1,3,4],[2,6]] Output: [1,1,2,3,4,4,5,6] Explanation: The linked-lists ar 阅读全文
posted @ 2021-02-19 22:31 alau 阅读(92) 评论(0) 推荐(0)