
二叉树递归调用顺序学习笔记(左 → 右 → 自己)
这篇是我做 124. Binary Tree Maximum Path Sum · 二叉树中的最大路径和 时整理的笔记。卡住我的不是公式,而是递归到底按什么顺序走。 This is a note from working on LeetCode 124. What tripped me up wasn’t the formula. It was the order the recursion actually runs in. 一句话总结本质: 每进入一个节点,先一路往左钻到底;左边返回后,同一个节点才去右边;进了右子树,又重新「先左后右」。两边都返回后,才处理自己。完整规则:左 → 右 → 自己(后序遍历,post-order)。 Every time you enter a node, you dive all the way left first. Once the left side returns, that same node goes right. Inside the right subtree, “left first, then right” starts over. Only after both sides return does the node process itself. The full rule: left → right → self (post-order). ...