<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Dp-on-Trees on</title><link>https://h30306.github.io/blog/zh-tw/tags/dp-on-trees/</link><description>Recent content in Dp-on-Trees 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>Sat, 31 Oct 2026 00:00:00 +0000</lastBuildDate><atom:link href="https://h30306.github.io/blog/zh-tw/tags/dp-on-trees/index.xml" rel="self" type="application/rss+xml"/><item><title>LeetCode 834: Sum of Distances in Tree</title><link>https://h30306.github.io/blog/zh-tw/leetcode/leetcode-834/</link><pubDate>Sat, 31 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-834/</guid><description>LeetCode 834 解題筆記：換根 DP：先以 0 為根算子樹大小和 ans[0]，再用 ans[child] = ans[parent] - size + (n - size) 推到每個節點</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/leetcode/leetcode-834/featured.png"/></item><item><title>LeetCode 968: Binary Tree Cameras</title><link>https://h30306.github.io/blog/zh-tw/leetcode/leetcode-968/</link><pubDate>Fri, 30 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-968/</guid><description>LeetCode 968 解題筆記：後序貪心，每個節點三種狀態：有相機、被覆蓋、沒被覆蓋；有小孩沒被覆蓋才放相機，最後根沒被覆蓋要補一台</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/leetcode/leetcode-968/featured.png"/></item><item><title>LeetCode 124: Binary Tree Maximum Path Sum</title><link>https://h30306.github.io/blog/zh-tw/leetcode/leetcode-124/</link><pubDate>Sat, 24 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-124/</guid><description>LeetCode 124 解題筆記：DFS 回傳往下的一條鏈，在每個節點用「左鏈 + 自己 + 右鏈」更新答案；負的鏈要丟掉</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/leetcode/leetcode-124/featured.png"/></item><item><title>LeetCode 1372: Longest ZigZag Path in a Binary Tree</title><link>https://h30306.github.io/blog/zh-tw/leetcode/leetcode-1372/</link><pubDate>Sat, 24 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-1372/</guid><description>LeetCode 1372 解題筆記：每個節點回傳兩個值：從這裡先往左、先往右的最長 zigzag；往左走接的是左小孩「先往右」的值</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/leetcode/leetcode-1372/featured.png"/></item><item><title>LeetCode 687: Longest Univalue Path</title><link>https://h30306.github.io/blog/zh-tw/leetcode/leetcode-687/</link><pubDate>Sat, 24 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-687/</guid><description>LeetCode 687 解題筆記：DFS 回傳往下同值的最長鏈（邊數），在每個節點用左 + 右更新答案</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/leetcode/leetcode-687/featured.png"/></item><item><title>LeetCode 563: Binary Tree Tilt</title><link>https://h30306.github.io/blog/zh-tw/leetcode/leetcode-563/</link><pubDate>Sat, 27 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-563/</guid><description>LeetCode 563 解題筆記：後序回傳子樹的總和，每個節點的 tilt 是左右子樹總和的差，加進答案</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/leetcode/leetcode-563/featured.png"/></item><item><title>LeetCode 543: Diameter of Binary Tree</title><link>https://h30306.github.io/blog/zh-tw/leetcode/leetcode-543/</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/zh-tw/leetcode/leetcode-543/</guid><description>LeetCode 543 解題筆記：直徑可能不經過根；後序回傳高度，同時在每個節點用「左高 + 右高」更新答案；算的是邊數</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/leetcode/leetcode-543/featured.png"/></item></channel></rss>