heap
Goofiness
这个作者很懒,什么都没留下…
展开
-
[LeetCode]Kth Largest Element in a Stream@Python
Kth Largest Element in a Stream Design a class to find the kth largest element in a stream. Note that it is the kth largest element in the sorted order, not the kth distinct element. Your KthLargest ...原创 2019-05-05 10:55:03 · 198 阅读 · 0 评论 -
[LeetCode]Last Stone Weight@Python
Last Stone Weight We have a collection of rocks, each rock has a positive integer weight. Each turn, we choose the two heaviest rocks and smash them together. Suppose the stones have weights x and y...原创 2019-05-22 09:33:11 · 272 阅读 · 0 评论 -
[LeetCode]Network Delay Time@Python
Network Delay Time There are N network nodes, labelled 1 to N. Given times, a list of travel times as directed edges times[i] = (u, v, w), where u is the source node, v is the target node, and w is t...原创 2019-05-16 00:13:28 · 130 阅读 · 0 评论 -
[LeetCode]Top K Frequent Words@Python
Top K Frequent Words Given a non-empty list of words, return the k most frequent elements. Your answer should be sorted by frequency from highest to lowest. If two words have the same frequency, then...原创 2019-05-14 23:27:36 · 100 阅读 · 0 评论 -
K Closest Points to Origin
K Closest Points to Origin We have a list of points on the plane. Find the K closest points to the origin (0, 0). (Here, the distance between two points on a plane is the Euclidean distance.) You ma...原创 2019-05-19 21:21:22 · 157 阅读 · 0 评论 -
[LeetCode]Cheapest Flights Within K Stops@Python
Cheapest Flights Within K Stops There are n cities connected by m flights. Each fight starts from city u and arrives at v with a price w. Now given all the cities and flights, together with starting ...原创 2019-05-19 21:11:28 · 133 阅读 · 0 评论 -
[LeetCode]Split Array into Consecutive Subsequences@Python
Split Array into Consecutive Subsequences You are given an integer array sorted in ascending order (may contain duplicates), you need to split them into several subsequences, where each subsequences ...原创 2019-05-14 10:08:56 · 92 阅读 · 0 评论 -
[LeetCode]Find K Pairs with Smallest Sums@Python
Find K Pairs with Smallest Sums You are given two integer arrays nums1 and nums2 sorted in ascending order and an integer k. Define a pair (u,v) which consists of one element from the first array and...原创 2019-05-09 06:32:25 · 110 阅读 · 0 评论 -
[LeetCode]Kth Largest Element in an Array@Python
Kth Largest Element in an Array Find the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element. Example Input: [3,2,1,5...原创 2019-05-05 11:20:13 · 127 阅读 · 0 评论 -
[LeetCode]Sort Characters By Frequency@Python
Sort Characters By Frequency Given a string, sort it in decreasing order based on the frequency of characters. Example Input: “tree” Output: “eert” Explanation: ‘e’ appears twice while ‘r’ and ...原创 2019-05-12 23:20:32 · 110 阅读 · 0 评论