<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Heap on</title><link>https://h30306.github.io/blog/zh-tw/tags/heap/</link><description>Recent content in Heap on</description><generator>Hugo -- gohugo.io</generator><language>zh-tw</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, 20 Oct 2026 00:00:00 +0000</lastBuildDate><atom:link href="https://h30306.github.io/blog/zh-tw/tags/heap/index.xml" rel="self" type="application/rss+xml"/><item><title>Heap 優先佇列</title><link>https://h30306.github.io/blog/zh-tw/algorithm/heap/</link><pubDate>Tue, 20 Oct 2026 00:00:00 +0000</pubDate><author>hwork0511@gmail.com (Wei Yi Chung)</author><guid>https://h30306.github.io/blog/zh-tw/algorithm/heap/</guid><description>heapq 基本用法、Top-K、lazy deletion、雙 heap、K 路合併、掃描線與 Dijkstra</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/algorithm/heap/featured.png"/></item><item><title>LeetCode 23: Merge k Sorted Lists</title><link>https://h30306.github.io/blog/zh-tw/leetcode/leetcode-23/</link><pubDate>Tue, 20 Oct 2026 00:00:00 +0000</pubDate><author>hwork0511@gmail.com (Wei Yi Chung)</author><guid>https://h30306.github.io/blog/zh-tw/leetcode/leetcode-23/</guid><description>LeetCode 23 解題筆記：heap 只放 k 個開頭，以及分治兩兩合併</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/leetcode/leetcode-23/featured.png"/></item><item><title>LeetCode 253: Meeting Rooms II</title><link>https://h30306.github.io/blog/zh-tw/leetcode/leetcode-253/</link><pubDate>Thu, 15 Oct 2026 00:00:00 +0000</pubDate><author>hwork0511@gmail.com (Wei Yi Chung)</author><guid>https://h30306.github.io/blog/zh-tw/leetcode/leetcode-253/</guid><description>LeetCode 253 解題筆記：heap 存進行中會議的結束時間，半開區間要用 &amp;lt;=</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/leetcode/leetcode-253/featured.png"/></item><item><title>LeetCode 716: Max Stack</title><link>https://h30306.github.io/blog/zh-tw/leetcode/leetcode-716/</link><pubDate>Mon, 14 Sep 2026 00:00:00 +0000</pubDate><author>hwork0511@gmail.com (Wei Yi Chung)</author><guid>https://h30306.github.io/blog/zh-tw/leetcode/leetcode-716/</guid><description>LeetCode 716 解題筆記：stack 和 heap 都存唯一 id，刪除只記 id，查詢時再丟掉已刪除的；用值記錄會分不清重複的元素</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/leetcode/leetcode-716/featured.png"/></item><item><title>LeetCode 2973: Find Number of Coins to Place in Tree Nodes</title><link>https://h30306.github.io/blog/zh-tw/leetcode/leetcode-2973/</link><pubDate>Sat, 12 Sep 2026 00:00:00 +0000</pubDate><author>hwork0511@gmail.com (Wei Yi Chung)</author><guid>https://h30306.github.io/blog/zh-tw/leetcode/leetcode-2973/</guid><description>LeetCode 2973 解題筆記：三個數的最大乘積只可能是「最大的三個」或「最小的兩個 × 最大的一個」；每個子樹只回傳最小 2 個和最大 3 個，後序合併</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/leetcode/leetcode-2973/featured.png"/></item><item><title>LeetCode 4046: Minimum Cost Path With At Most K Turns</title><link>https://h30306.github.io/blog/zh-tw/leetcode/leetcode-4046/</link><pubDate>Fri, 11 Sep 2026 00:00:00 +0000</pubDate><author>hwork0511@gmail.com (Wei Yi Chung)</author><guid>https://h30306.github.io/blog/zh-tw/leetcode/leetcode-4046/</guid><description>LeetCode 4046 解題筆記：Dijkstra 的狀態加上「上一步方向」和「已轉彎數」；同一格同方向時，先處理的成本較低，轉彎數也較少的話就支配後面的狀態</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/leetcode/leetcode-4046/featured.png"/></item><item><title>LeetCode 1425: Constrained Subsequence Sum</title><link>https://h30306.github.io/blog/zh-tw/leetcode/leetcode-1425/</link><pubDate>Thu, 10 Sep 2026 00:00:00 +0000</pubDate><author>hwork0511@gmail.com (Wei Yi Chung)</author><guid>https://h30306.github.io/blog/zh-tw/leetcode/leetcode-1425/</guid><description>LeetCode 1425 解題筆記：dp[i] = nums[i] + max(0, 前 k 個 dp 的最大值)；前 k 個 dp 的最大值是滑動視窗最大值，用單調佇列 O(1) 取得</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/leetcode/leetcode-1425/featured.png"/></item><item><title>LeetCode 1354: Construct Target Array With Multiple Sums</title><link>https://h30306.github.io/blog/zh-tw/leetcode/leetcode-1354/</link><pubDate>Mon, 07 Sep 2026 00:00:00 +0000</pubDate><author>hwork0511@gmail.com (Wei Yi Chung)</author><guid>https://h30306.github.io/blog/zh-tw/leetcode/leetcode-1354/</guid><description>LeetCode 1354 解題筆記：反著做，最大值一定是最後被設定的；差距大時用取餘數一次跳完</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/leetcode/leetcode-1354/featured.png"/></item><item><title>LeetCode 499: The Maze III</title><link>https://h30306.github.io/blog/zh-tw/leetcode/leetcode-499/</link><pubDate>Sun, 06 Sep 2026 00:00:00 +0000</pubDate><author>hwork0511@gmail.com (Wei Yi Chung)</author><guid>https://h30306.github.io/blog/zh-tw/leetcode/leetcode-499/</guid><description>LeetCode 499 解題筆記：Dijkstra 的優先度用 (距離, 路徑字串)，滾動途中經過洞就要停下</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/leetcode/leetcode-499/featured.png"/></item><item><title>LeetCode 2163: Minimum Difference in Sums After Removal of Elements</title><link>https://h30306.github.io/blog/zh-tw/leetcode/leetcode-2163/</link><pubDate>Sat, 05 Sep 2026 00:00:00 +0000</pubDate><author>hwork0511@gmail.com (Wei Yi Chung)</author><guid>https://h30306.github.io/blog/zh-tw/leetcode/leetcode-2163/</guid><description>LeetCode 2163 解題筆記：枚舉第一段和第二段的分界 k；左邊 nums[:k] 選 n 個最小的（最大堆維護），右邊 nums[k:] 選 n 個最大的（最小堆維護），前後綴各掃一次</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/leetcode/leetcode-2163/featured.png"/></item><item><title>LeetCode 2102: Sequentially Ordinal Rank Tracker</title><link>https://h30306.github.io/blog/zh-tw/leetcode/leetcode-2102/</link><pubDate>Sat, 01 Aug 2026 00:00:00 +0000</pubDate><author>hwork0511@gmail.com (Wei Yi Chung)</author><guid>https://h30306.github.io/blog/zh-tw/leetcode/leetcode-2102/</guid><description>LeetCode 2102 解題筆記：雙 heap 維持「前 k 名」和「其他」，自訂 &lt;strong>lt&lt;/strong> 處理字串的反向比較</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/leetcode/leetcode-2102/featured.png"/></item><item><title>LeetCode 1878: Get Biggest Three Rhombus Sums in a Grid</title><link>https://h30306.github.io/blog/zh-tw/leetcode/leetcode-1878/</link><pubDate>Tue, 23 Jun 2026 00:00:00 +0000</pubDate><author>hwork0511@gmail.com (Wei Yi Chung)</author><guid>https://h30306.github.io/blog/zh-tw/leetcode/leetcode-1878/</guid><description>LeetCode 1878 解題筆記：枚舉每個頂點和大小，沿四條邊走一圈加總，取前三大的不同值</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/leetcode/leetcode-1878/featured.png"/></item><item><title>LeetCode 759: Employee Free Time</title><link>https://h30306.github.io/blog/zh-tw/leetcode/leetcode-759/</link><pubDate>Sun, 03 May 2026 00:00:00 +0000</pubDate><author>hwork0511@gmail.com (Wei Yi Chung)</author><guid>https://h30306.github.io/blog/zh-tw/leetcode/leetcode-759/</guid><description>LeetCode 759 解題筆記：用 K 路合併依開始時間掃過所有工作區間，目前最晚結束時間之後的空檔就是共同空閒</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/leetcode/leetcode-759/featured.png"/></item><item><title>LeetCode 1514: Path with Maximum Probability</title><link>https://h30306.github.io/blog/zh-tw/leetcode/leetcode-1514/</link><pubDate>Fri, 17 Apr 2026 00:00:00 +0000</pubDate><author>hwork0511@gmail.com (Wei Yi Chung)</author><guid>https://h30306.github.io/blog/zh-tw/leetcode/leetcode-1514/</guid><description>LeetCode 1514 解題筆記：機率相乘只會變小，所以 Dijkstra 可以直接用；剪枝要用 &amp;lt;=</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/leetcode/leetcode-1514/featured.png"/></item><item><title>LeetCode 3885: Design Event Manager</title><link>https://h30306.github.io/blog/zh-tw/leetcode/leetcode-3885/</link><pubDate>Sun, 29 Mar 2026 00:00:00 +0000</pubDate><author>hwork0511@gmail.com (Wei Yi Chung)</author><guid>https://h30306.github.io/blog/zh-tw/leetcode/leetcode-3885/</guid><description>LeetCode 3885 解題筆記：dict 存目前優先度，max-heap 加 lazy deletion，彈出時再驗證</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/leetcode/leetcode-3885/featured.png"/></item><item><title>LeetCode 2054: Two Best Non-Overlapping Events</title><link>https://h30306.github.io/blog/zh-tw/leetcode/leetcode-2054/</link><pubDate>Wed, 04 Feb 2026 00:00:00 +0000</pubDate><author>hwork0511@gmail.com (Wei Yi Chung)</author><guid>https://h30306.github.io/blog/zh-tw/leetcode/leetcode-2054/</guid><description>LeetCode 2054 解題筆記：只能選兩個，所以對每個活動，加上「在它開始前就結束的活動裡價值最大的」；依結束時間排序，前綴最大值 + 二分搜尋</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/leetcode/leetcode-2054/featured.png"/></item><item><title>LeetCode 3815: Design Auction System</title><link>https://h30306.github.io/blog/zh-tw/leetcode/leetcode-3815/</link><pubDate>Sun, 18 Jan 2026 00:00:00 +0000</pubDate><author>hwork0511@gmail.com (Wei Yi Chung)</author><guid>https://h30306.github.io/blog/zh-tw/leetcode/leetcode-3815/</guid><description>LeetCode 3815 解題筆記：每個商品一個 max-heap，出價改變就推新的一筆，查詢時丟掉過期的</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/leetcode/leetcode-3815/featured.png"/></item><item><title>LeetCode 632: Smallest Range Covering Elements from K Lists</title><link>https://h30306.github.io/blog/zh-tw/leetcode/leetcode-632/</link><pubDate>Sun, 18 Jan 2026 00:00:00 +0000</pubDate><author>hwork0511@gmail.com (Wei Yi Chung)</author><guid>https://h30306.github.io/blog/zh-tw/leetcode/leetcode-632/</guid><description>LeetCode 632 解題筆記：heap 放每條 list 的目前元素，同時記錄最大值，每次推進最小的那條</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/leetcode/leetcode-632/featured.png"/></item><item><title>LeetCode 1696: Jump Game VI</title><link>https://h30306.github.io/blog/zh-tw/leetcode/leetcode-1696/</link><pubDate>Sun, 10 Aug 2025 00:00:00 +0000</pubDate><author>hwork0511@gmail.com (Wei Yi Chung)</author><guid>https://h30306.github.io/blog/zh-tw/leetcode/leetcode-1696/</guid><description>LeetCode 1696 解題筆記：dp[i] = nums[i] + 前 k 個 dp 的最大值；前 k 個的最大值用單調佇列維護，O(n)</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/leetcode/leetcode-1696/featured.png"/></item><item><title>LeetCode 2402: Meeting Rooms III</title><link>https://h30306.github.io/blog/zh-tw/leetcode/leetcode-2402/</link><pubDate>Thu, 17 Jul 2025 00:00:00 +0000</pubDate><author>hwork0511@gmail.com (Wei Yi Chung)</author><guid>https://h30306.github.io/blog/zh-tw/leetcode/leetcode-2402/</guid><description>LeetCode 2402 解題筆記：空閒房間和忙碌房間各一個 heap，延後的會議要保留原本的長度</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/leetcode/leetcode-2402/featured.png"/></item><item><title>LeetCode 1353: Maximum Number of Events That Can Be Attended</title><link>https://h30306.github.io/blog/zh-tw/leetcode/leetcode-1353/</link><pubDate>Mon, 07 Jul 2025 00:00:00 +0000</pubDate><author>hwork0511@gmail.com (Wei Yi Chung)</author><guid>https://h30306.github.io/blog/zh-tw/leetcode/leetcode-1353/</guid><description>LeetCode 1353 解題筆記：每天參加「最早結束」的活動，用 min-heap 存結束日</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/leetcode/leetcode-1353/featured.png"/></item><item><title>LeetCode 3607: Power Grid Maintenance</title><link>https://h30306.github.io/blog/zh-tw/leetcode/leetcode-3607/</link><pubDate>Sun, 06 Jul 2025 00:00:00 +0000</pubDate><author>hwork0511@gmail.com (Wei Yi Chung)</author><guid>https://h30306.github.io/blog/zh-tw/leetcode/leetcode-3607/</guid><description>LeetCode 3607 解題筆記：Union-Find 分群，每群一個 min-heap，離線的站用 lazy deletion</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/leetcode/leetcode-3607/featured.png"/></item></channel></rss>