<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Divide-and-Conquer on</title><link>https://h30306.github.io/blog/zh-tw/tags/divide-and-conquer/</link><description>Recent content in Divide-and-Conquer 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>Thu, 29 Oct 2026 00:00:00 +0000</lastBuildDate><atom:link href="https://h30306.github.io/blog/zh-tw/tags/divide-and-conquer/index.xml" rel="self" type="application/rss+xml"/><item><title>LeetCode 889: Construct Binary Tree from Preorder and Postorder Traversal</title><link>https://h30306.github.io/blog/zh-tw/leetcode/leetcode-889/</link><pubDate>Thu, 29 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-889/</guid><description>LeetCode 889 解題筆記：stack 存目前這條路徑，堆頂等於 postorder 的下一個就代表子樹完成要 pop；新節點先接左邊</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/leetcode/leetcode-889/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>Merge Sort 與分治計數</title><link>https://h30306.github.io/blog/zh-tw/algorithm/merge-sort/</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/merge-sort/</guid><description>Merge sort 模板、逆序對類計數題的計數位置、linked list 版本與常見錯誤</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/algorithm/merge-sort/featured.png"/></item><item><title>LeetCode 2426: Number of Pairs Satisfying Inequality</title><link>https://h30306.github.io/blog/zh-tw/leetcode/leetcode-2426/</link><pubDate>Mon, 19 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-2426/</guid><description>LeetCode 2426 解題筆記：先化簡式子，再判斷符合的是前綴還是後綴</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/leetcode/leetcode-2426/featured.png"/></item><item><title>LeetCode 493: Reverse Pairs</title><link>https://h30306.github.io/blog/zh-tw/leetcode/leetcode-493/</link><pubDate>Mon, 19 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-493/</guid><description>LeetCode 493 解題筆記：計數條件和排序條件不同時，先掃再合併</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/leetcode/leetcode-493/featured.png"/></item><item><title>LeetCode 315: Count of Smaller Numbers After Self</title><link>https://h30306.github.io/blog/zh-tw/leetcode/leetcode-315/</link><pubDate>Sun, 18 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-315/</guid><description>LeetCode 315 解題筆記：帶 index 的 merge sort，以及 BIT 解法</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/leetcode/leetcode-315/featured.png"/></item><item><title>LeetCode 912: Sort an Array</title><link>https://h30306.github.io/blog/zh-tw/leetcode/leetcode-912/</link><pubDate>Sun, 18 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-912/</guid><description>LeetCode 912 解題筆記：手寫 merge sort，以及兩次寫錯的地方</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/leetcode/leetcode-912/featured.png"/></item><item><title>LeetCode LCR 170: 交易逆序對的總數</title><link>https://h30306.github.io/blog/zh-tw/leetcode/leetcode-lcr-170/</link><pubDate>Sun, 18 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-lcr-170/</guid><description>LCR 170（劍指 Offer 51）解題筆記：merge 時順便數逆序對</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/leetcode/leetcode-lcr-170/featured.png"/></item><item><title>LeetCode 327: Count of Range Sum</title><link>https://h30306.github.io/blog/zh-tw/leetcode/leetcode-327/</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-327/</guid><description>LeetCode 327 解題筆記：前綴和 + merge sort 計數，兩個指針卡出區間；重打十幾次的練習紀錄</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/leetcode/leetcode-327/featured.png"/></item><item><title>LeetCode 1763: Longest Nice Substring</title><link>https://h30306.github.io/blog/zh-tw/leetcode/leetcode-1763/</link><pubDate>Sat, 17 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-1763/</guid><description>LeetCode 1763 解題筆記：沒有大小寫配對的字元一定不在答案裡，用它切開字串遞迴；長度相同時取左邊的</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/leetcode/leetcode-1763/featured.png"/></item><item><title>LeetCode 395: Longest Substring with At Least K Repeating Characters</title><link>https://h30306.github.io/blog/zh-tw/leetcode/leetcode-395/</link><pubDate>Sat, 17 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-395/</guid><description>LeetCode 395 解題筆記：「每個字元至少 k 次」不單調，不能直接滑動；分治法用出現不到 k 次的字元切開，或枚舉視窗裡有幾種字元，固定種類數後就能滑動</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/leetcode/leetcode-395/featured.png"/></item><item><title>LeetCode 109: Convert Sorted List to Binary Search Tree</title><link>https://h30306.github.io/blog/zh-tw/leetcode/leetcode-109/</link><pubDate>Sat, 19 Nov 2022 00:00:00 +0000</pubDate><author>hwork0511@gmail.com (Wei Yi Chung)</author><guid>https://h30306.github.io/blog/zh-tw/leetcode/leetcode-109/</guid><description>LeetCode 109 解題筆記：快慢指針找中點當根，左右兩半遞迴建樹；高度自然平衡</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/leetcode/leetcode-109/featured.png"/></item><item><title>LeetCode 148: Sort List</title><link>https://h30306.github.io/blog/zh-tw/leetcode/leetcode-148/</link><pubDate>Thu, 17 Nov 2022 00:00:00 +0000</pubDate><author>hwork0511@gmail.com (Wei Yi Chung)</author><guid>https://h30306.github.io/blog/zh-tw/leetcode/leetcode-148/</guid><description>LeetCode 148 解題筆記：用快慢指針切成兩半，遞迴排序後合併；O(n log n)，不需要額外陣列</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/leetcode/leetcode-148/featured.png"/></item><item><title>LeetCode 324: Wiggle Sort II</title><link>https://h30306.github.io/blog/zh-tw/leetcode/leetcode-324/</link><pubDate>Thu, 17 Nov 2022 00:00:00 +0000</pubDate><author>hwork0511@gmail.com (Wei Yi Chung)</author><guid>https://h30306.github.io/blog/zh-tw/leetcode/leetcode-324/</guid><description>LeetCode 324 解題筆記：排序後分成小的一半和大的一半，各自反轉後交錯放：小的放偶數位置、大的放奇數位置</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/leetcode/leetcode-324/featured.png"/></item><item><title>LeetCode 240: Search a 2D Matrix II</title><link>https://h30306.github.io/blog/zh-tw/leetcode/leetcode-240/</link><pubDate>Sat, 12 Nov 2022 00:00:00 +0000</pubDate><author>hwork0511@gmail.com (Wei Yi Chung)</author><guid>https://h30306.github.io/blog/zh-tw/leetcode/leetcode-240/</guid><description>LeetCode 240 解題筆記：從右上角開始，比目標大就往左、比目標小就往下，每一步排除一整列或一整欄</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/leetcode/leetcode-240/featured.png"/></item><item><title>LeetCode 106: Construct Binary Tree from Inorder and Postorder Traversal</title><link>https://h30306.github.io/blog/zh-tw/leetcode/leetcode-106/</link><pubDate>Thu, 10 Nov 2022 00:00:00 +0000</pubDate><author>hwork0511@gmail.com (Wei Yi Chung)</author><guid>https://h30306.github.io/blog/zh-tw/leetcode/leetcode-106/</guid><description>LeetCode 106 解題筆記：後序的最後一個是根；從後序尾巴往前取根時，要先建右子樹再建左子樹</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/leetcode/leetcode-106/featured.png"/></item><item><title>LeetCode 105: Construct Binary Tree from Preorder and Inorder Traversal</title><link>https://h30306.github.io/blog/zh-tw/leetcode/leetcode-105/</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/zh-tw/leetcode/leetcode-105/</guid><description>LeetCode 105 解題筆記：前序的第一個是根，在中序裡找到根的位置就知道左子樹有幾個節點；用字典查位置，O(n)</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/leetcode/leetcode-105/featured.png"/></item><item><title>LeetCode 215: Kth Largest Element in an Array</title><link>https://h30306.github.io/blog/zh-tw/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/zh-tw/leetcode/leetcode-215/</guid><description>LeetCode 215 解題筆記：維持大小為 k 的 min-heap，堆頂就是第 k 大；或用 quickselect 平均 O(n)</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 973: K Closest Points to Origin</title><link>https://h30306.github.io/blog/zh-tw/leetcode/leetcode-973/</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/zh-tw/leetcode/leetcode-973/</guid><description>LeetCode 973 解題筆記：跟 Top-K 一樣，用大小為 k 的 max-heap（存負的距離）保留最近的 k 個點</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/leetcode/leetcode-973/featured.png"/></item><item><title>LeetCode 347: Top K Frequent Elements</title><link>https://h30306.github.io/blog/zh-tw/leetcode/leetcode-347/</link><pubDate>Thu, 27 Oct 2022 00:00:00 +0000</pubDate><author>hwork0511@gmail.com (Wei Yi Chung)</author><guid>https://h30306.github.io/blog/zh-tw/leetcode/leetcode-347/</guid><description>LeetCode 347 解題筆記：先計數，再用大小為 k 的 heap 或 bucket sort（次數當 index）取出次數最多的 k 個</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/leetcode/leetcode-347/featured.png"/></item><item><title>LeetCode 169: Majority Element</title><link>https://h30306.github.io/blog/zh-tw/leetcode/leetcode-169/</link><pubDate>Sat, 20 Aug 2022 00:00:00 +0000</pubDate><author>hwork0511@gmail.com (Wei Yi Chung)</author><guid>https://h30306.github.io/blog/zh-tw/leetcode/leetcode-169/</guid><description>LeetCode 169 解題筆記：Boyer-Moore 投票，不同的數兩兩抵消，最後留下的就是出現超過一半的那個</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/leetcode/leetcode-169/featured.png"/></item><item><title>LeetCode 108: Convert Sorted Array to Binary Search Tree</title><link>https://h30306.github.io/blog/zh-tw/leetcode/leetcode-108/</link><pubDate>Tue, 16 Aug 2022 00:00:00 +0000</pubDate><author>hwork0511@gmail.com (Wei Yi Chung)</author><guid>https://h30306.github.io/blog/zh-tw/leetcode/leetcode-108/</guid><description>LeetCode 108 解題筆記：中間的元素當根，左右兩半遞迴；左右大小最多差 1，自然是平衡的</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/leetcode/leetcode-108/featured.png"/></item></channel></rss>