<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Heap-Priority-Queue on</title><link>https://h30306.github.io/blog/tags/heap-priority-queue/</link><description>Recent content in Heap-Priority-Queue on</description><generator>Hugo -- gohugo.io</generator><language>en</language><managingEditor>hwork0511@gmail.com (Wei Yi Chung)</managingEditor><webMaster>hwork0511@gmail.com (Wei Yi Chung)</webMaster><copyright>© 2026 Wei Yi Chung</copyright><lastBuildDate>Tue, 22 Nov 2022 00:00:00 +0000</lastBuildDate><atom:link href="https://h30306.github.io/blog/tags/heap-priority-queue/index.xml" rel="self" type="application/rss+xml"/><item><title>LeetCode 2099: Find Subsequence of Length K With the Largest Sum</title><link>https://h30306.github.io/blog/leetcode/leetcode-2099/</link><pubDate>Tue, 22 Nov 2022 00:00:00 +0000</pubDate><author>hwork0511@gmail.com (Wei Yi Chung)</author><guid>https://h30306.github.io/blog/leetcode/leetcode-2099/</guid><description>LeetCode 2099 note: pick the k largest values along with their indices, then sort by index to restore the original order</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/leetcode/leetcode-2099/featured.png"/></item><item><title>LeetCode 2231: Largest Number After Digit Swaps by Parity</title><link>https://h30306.github.io/blog/leetcode/leetcode-2231/</link><pubDate>Tue, 22 Nov 2022 00:00:00 +0000</pubDate><author>hwork0511@gmail.com (Wei Yi Chung)</author><guid>https://h30306.github.io/blog/leetcode/leetcode-2231/</guid><description>LeetCode 2231 note: odd digits swap only with odd digits and even with even; sort each group and refill each position with the largest digit of its parity</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/leetcode/leetcode-2231/featured.png"/></item><item><title>LeetCode 2335: Minimum Amount of Time to Fill Cups</title><link>https://h30306.github.io/blog/leetcode/leetcode-2335/</link><pubDate>Tue, 22 Nov 2022 00:00:00 +0000</pubDate><author>hwork0511@gmail.com (Wei Yi Chung)</author><guid>https://h30306.github.io/blog/leetcode/leetcode-2335/</guid><description>LeetCode 2335 note: the answer is max(the largest count, ceil(total / 2)); simulating means filling one cup from each of the two largest every second</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/leetcode/leetcode-2335/featured.png"/></item><item><title>LeetCode 1337: The K Weakest Rows in a Matrix</title><link>https://h30306.github.io/blog/leetcode/leetcode-1337/</link><pubDate>Mon, 21 Nov 2022 00:00:00 +0000</pubDate><author>hwork0511@gmail.com (Wei Yi Chung)</author><guid>https://h30306.github.io/blog/leetcode/leetcode-1337/</guid><description>LeetCode 1337 note: soldiers come first in each row, so binary search the first 0 for the count; sort by (count, row index) and take k</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/leetcode/leetcode-1337/featured.png"/></item><item><title>LeetCode 1464: Maximum Product of Two Elements in an Array</title><link>https://h30306.github.io/blog/leetcode/leetcode-1464/</link><pubDate>Mon, 21 Nov 2022 00:00:00 +0000</pubDate><author>hwork0511@gmail.com (Wei Yi Chung)</author><guid>https://h30306.github.io/blog/leetcode/leetcode-1464/</guid><description>LeetCode 1464 note: all values are positive, so take the two largest a and b and return (a - 1)(b - 1)</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/leetcode/leetcode-1464/featured.png"/></item><item><title>LeetCode 264: Ugly Number II</title><link>https://h30306.github.io/blog/leetcode/leetcode-264/</link><pubDate>Mon, 14 Nov 2022 00:00:00 +0000</pubDate><author>hwork0511@gmail.com (Wei Yi Chung)</author><guid>https://h30306.github.io/blog/leetcode/leetcode-264/</guid><description>LeetCode 264 note: three pointers mark the next ugly numbers to multiply by 2, 3 and 5; take the minimum each time and advance every pointer that produced it</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/leetcode/leetcode-264/featured.png"/></item><item><title>LeetCode 215: Kth Largest Element in an Array</title><link>https://h30306.github.io/blog/leetcode/leetcode-215/</link><pubDate>Sat, 29 Oct 2022 00:00:00 +0000</pubDate><author>hwork0511@gmail.com (Wei Yi Chung)</author><guid>https://h30306.github.io/blog/leetcode/leetcode-215/</guid><description>LeetCode 215 note: keep a min-heap of size k whose top is the k-th largest, or use quickselect for O(n) on average</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/leetcode/leetcode-215/featured.png"/></item><item><title>LeetCode 1046: Last Stone Weight</title><link>https://h30306.github.io/blog/leetcode/leetcode-1046/</link><pubDate>Fri, 30 Sep 2022 00:00:00 +0000</pubDate><author>hwork0511@gmail.com (Wei Yi Chung)</author><guid>https://h30306.github.io/blog/leetcode/leetcode-1046/</guid><description>LeetCode 1046 note: from a max-heap (negated values) take the two heaviest each round, push back their difference if unequal, and return the last stone or 0</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/leetcode/leetcode-1046/featured.png"/></item><item><title>LeetCode 703: Kth Largest Element in a Stream</title><link>https://h30306.github.io/blog/leetcode/leetcode-703/</link><pubDate>Wed, 31 Aug 2022 00:00:00 +0000</pubDate><author>hwork0511@gmail.com (Wei Yi Chung)</author><guid>https://h30306.github.io/blog/leetcode/leetcode-703/</guid><description>LeetCode 703 note: keep a min-heap of size k; its top is the k-th largest</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/leetcode/leetcode-703/featured.png"/></item><item><title>LeetCode 506: Relative Ranks</title><link>https://h30306.github.io/blog/leetcode/leetcode-506/</link><pubDate>Thu, 25 Aug 2022 00:00:00 +0000</pubDate><author>hwork0511@gmail.com (Wei Yi Chung)</author><guid>https://h30306.github.io/blog/leetcode/leetcode-506/</guid><description>LeetCode 506 note: sort indices by score descending, give medals to the top three and rank strings to the rest, writing back into the original positions</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/leetcode/leetcode-506/featured.png"/></item></channel></rss>