{"id":443,"date":"2026-02-06T22:23:15","date_gmt":"2026-02-06T14:23:15","guid":{"rendered":"https:\/\/jdoxk3.cn\/?p=443"},"modified":"2026-02-06T22:23:15","modified_gmt":"2026-02-06T14:23:15","slug":"%e4%bb%a3%e7%a0%81%e9%9a%8f%e6%83%b3%e5%bd%95%e7%ae%97%e6%b3%95%e8%ae%ad%e7%bb%83%e8%90%a5%e7%ac%ac%e5%8d%81%e5%85%ad%e5%a4%a9-513-%e6%89%be%e6%a0%91%e5%b7%a6%e4%b8%8b%e8%a7%92%e7%9a%84%e5%80%bc","status":"publish","type":"post","link":"https:\/\/jdoxk3.cn\/index.php\/2026\/02\/06\/%e4%bb%a3%e7%a0%81%e9%9a%8f%e6%83%b3%e5%bd%95%e7%ae%97%e6%b3%95%e8%ae%ad%e7%bb%83%e8%90%a5%e7%ac%ac%e5%8d%81%e5%85%ad%e5%a4%a9-513-%e6%89%be%e6%a0%91%e5%b7%a6%e4%b8%8b%e8%a7%92%e7%9a%84%e5%80%bc\/","title":{"rendered":"\u4ee3\u7801\u968f\u60f3\u5f55\u7b97\u6cd5\u8bad\u7ec3\u8425\u7b2c\u5341\u516d\u5929 | 513.\u627e\u6811\u5de6\u4e0b\u89d2\u7684\u503c\uff0c112.\u8def\u5f84\u603b\u548c\uff0c106.\u4ece\u4e2d\u5e8f\u4e0e\u540e\u5e8f\u904d\u5386\u5e8f\u5217\u6784\u9020\u4e8c\u53c9\u6811"},"content":{"rendered":"\n<h1 class=\"wp-block-heading\">\u524d\u8a00<\/h1>\n\n\n\n<p>\u4eca\u5929\u662f\u7b97\u6cd5\u8bad\u7ec3\u8425\u7684\u7b2c\u5341\u516d\u5929\uff1f\u5b9e\u5219\u5e76\u975e\uff0c\u4e2d\u95f4\u7a7a\u4e86\u9760\u8fd18\u7bc7\u7684\u603b\u7ed3\u6ca1\u5199\uff0c\u5149\u505a\u9898\u4e0d\u5199\u603b\u7ed3\u6548\u679c\u5dee\u7684\u79bb\u8c31\u3002\u7ec8\u4e8e\uff0c\u5fd9\u788c\uff08\u4e0d\u77e5\u9053\u5fd9\u4ec0\u4e48\uff1f\uff09\u7684\u751f\u6d3b\u91cd\u65b0\u56de\u5230\u6b63\u8f68\uff0c\u56de\u5934\u8865\u5168\u5148\u524d\u7f3a\u4e0b\u7684\u7b14\u8bb0\u3002<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">513.\u627e\u6811\u5de6\u4e0b\u89d2\u7684\u503c<\/h1>\n\n\n\n<p>\u9898\u76ee\u94fe\u63a5\uff1a<a href=\"https:\/\/leetcode.cn\/problems\/find-bottom-left-tree-value\/\">513. \u627e\u6811\u5de6\u4e0b\u89d2\u7684\u503c<\/a><\/p>\n\n\n\n<p>\u9898\u76ee\u63cf\u8ff0\uff1a<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>\u7ed9\u5b9a\u4e00\u4e2a\u4e8c\u53c9\u6811\u7684 <strong>\u6839\u8282\u70b9<\/strong> <code>root<\/code>\uff0c\u8bf7\u627e\u51fa\u8be5\u4e8c\u53c9\u6811\u7684 <strong>\u6700\u5e95\u5c42 \u6700\u5de6\u8fb9<\/strong> \u8282\u70b9\u7684\u503c\u3002<\/p>\n\n\n\n<p>\u5047\u8bbe\u4e8c\u53c9\u6811\u4e2d\u81f3\u5c11\u6709\u4e00\u4e2a\u8282\u70b9\u3002<\/p>\n<\/blockquote>\n\n\n\n<h2 class=\"wp-block-heading\">\u601d\u8def<\/h2>\n\n\n\n<p>\u60f3\u8981\u627e\u5230\u6700\u540e\u4e00\u5c42\u6700\u5de6\u8fb9\u7684\u7684\u8282\u70b9\uff0c\u90a3\u4e48\u770b\u5230\u8fd9\u91cc\u80af\u5b9a\u60f3\u5230\u7528\u5c42\u5e8f\u904d\u5386\u662f\u6700\u7b80\u5355\u7684\u4e86\uff0c\u6211\u4eec\u53ea\u8981\u8fd4\u56de\u6700\u540e\u4e00\u5c42\u7684\u7b2c\u4e00\u4e2a\u5143\u7d20\u5373\u53ef\uff0c\u6240\u4ee5\u4e0d\u5177\u4f53\u8bb2\u4e86\u3002<\/p>\n\n\n\n<p>\u4e0b\u9762\uff0c\u6211\u4eec\u6765\u8bf4\u8bf4\u9012\u5f52\u6cd5\u5982\u4f55\u5b9e\u73b0\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u9012\u5f52\u6cd5<\/h3>\n\n\n\n<p>\u8bf4\u5230\u9012\u5f52\u6cd5\uff0c\u60f3\u5230\u7684\u80af\u5b9a\u662f\u7528\u524d\u5e8f\u904d\u5386\u76f4\u63a5\u5411\u5de6\u904d\u5386\u5230\u6700\u540e\u4e00\u4e2a\u5143\u7d20\u5c31\u8fd4\u56de\uff0c\u4f46\u8fd9\u80af\u5b9a\u4e0d\u5bf9\u3002\u6700\u5de6\u8fb9\u7684\u5143\u7d20\u4e0d\u4e00\u5b9a\u662f\u6700\u540e\u4e00\u5c42\uff0c\u6240\u4ee5\uff0c\u6839\u636e\u9898\u76ee\u9700\u6c42\uff1a\u9996\u5148\u662f\u6700\u540e\u4e00\u5c42\uff0c\u7136\u540e\u518d\u662f\u6700\u5de6\u8fb9\u3002<\/p>\n\n\n\n<p>\u90a3\u4e48\uff0c\u4f7f\u7528\u9012\u5f52\u6cd5\u8981\u600e\u4e48\u5224\u65ad\u662f\u4e0d\u662f\u6700\u540e\u4e00\u5c42\u5462\uff1f\u5b9e\u9645\u4e0a\u8bb0\u5f55\u4e0b\u6df1\u5ea6\uff0c\u6df1\u5ea6\u6700\u5927\u7684\u5c31\u662f\u6700\u540e\u4e00\u5c42\u3002\u60f3\u627e\u6700\u5de6\u8fb9\u7684\u5143\u7d20\u5c31\u53ea\u8981\u7528\u524d\u5e8f\u904d\u5386\uff08\u54ea\u4e2a\u90fd\u65e0\u6240\u8c13\uff0c\u53cd\u6b63\u4e0d\u8981\u5904\u7406\u4e2d\uff09\u4fdd\u8bc1\u5de6\u8fb9\u641c\u7d22\u4f18\u5148\uff0c\u8bb0\u5f55\u6df1\u5ea6\u6700\u5927\u7684\u53f6\u5b50\u8282\u70b9\u5c31\u597d\u3002<\/p>\n\n\n\n<p>\u63a5\u4e0b\u6765\u662f\u9012\u5f52\u4e09\u90e8\u66f2\uff1a<\/p>\n\n\n\n<p><strong>1.\u786e\u5b9a\u9012\u5f52\u51fd\u6570\u7684\u53c2\u6570\u548c\u8fd4\u56de\u503c<\/strong><\/p>\n\n\n\n<p>\u53c2\u6570\u5f97\u6709\u6839\u8282\u70b9\uff0c\u4e3a\u4e86\u8bb0\u5f55\u6700\u957f\u6df1\u5ea6\u6211\u4eec\u8fd8\u9700\u8981\u4e00\u4e2a\u6df1\u5ea6\u53c2\u6570\u3002<\/p>\n\n\n\n<p>\u4e0d\u9700\u8981\u8fd4\u56de\u503c<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>def traversal(self, root, depth):<\/code><\/pre>\n\n\n\n<p><strong>2.\u786e\u5b9a\u7ec8\u6b62\u6761\u4ef6<\/strong><\/p>\n\n\n\n<p>\u5f53\u9047\u5230\u53f6\u5b50\u8282\u70b9\u7684\u65f6\u5019\u8bf4\u660e\u6211\u4eec\u5df2\u7ecf\u904d\u5386\u5230\u5e95\u4e86\uff0c\u8fd9\u65f6\u5019\u9700\u8981\u8bb0\u5f55\u4e00\u4e0b\u6700\u5927\u6df1\u5ea6\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>if root.left == None and root.right == None:\n    if (depth > maxDepth):\n        maxDepth = depth\n        result = root.val\n    return<\/code><\/pre>\n\n\n\n<p><strong>3.\u786e\u5b9a\u5355\u5c42\u9012\u5f52\u903b\u8f91<\/strong><\/p>\n\n\n\n<p>\u4f7f\u7528\u56de\u6eaf\u6765\u8bb0\u5f55\u6bcf\u4e2a\u5143\u7d20\u7684\u6df1\u5ea6<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>if root.left:\n    depth += 1\n    self.traversal(root.left, depth)\n    depth -= 1\nif root.right:\n    depth += 1\n    self.traversal(root.right, depth)\n    depth -= 1<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u5b8c\u6210\u5b9e\u73b0\u5199\u6cd5<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">\u5c42\u5e8f\u904d\u5386\u6cd5<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code># Definition for a binary tree node.\n# class TreeNode:\n#     def __init__(self, val=0, left=None, right=None):\n#         self.val = val\n#         self.left = left\n#         self.right = right\nclass Solution:\n    def findBottomLeftValue(self, root: Optional&#91;TreeNode]) -> int:\n        if not root:\n            return 0\n        queue = collections.deque(&#91;root])\n        ans = 0\n        while queue:\n            levelSize = len(queue)\n            ans = queue&#91;0].val\n            for _ in range(levelSize):\n                node = queue.popleft()\n                if node.left: queue.append(node.left)\n                if node.right: queue.append(node.right)\n        return ans<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u9012\u5f52\u6cd5<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code># Definition for a binary tree node.\n# class TreeNode:\n#     def __init__(self, val=0, left=None, right=None):\n#         self.val = val\n#         self.left = left\n#         self.right = right\nclass Solution:\n    def __init__(self, result = 0, depth = 0):\n        self.maxDepth = depth\n        self.result = result\n\n    def traversal(self, root, depth):\n        if root.left == None and root.right == None:\n            if (depth > self.maxDepth):\n                self.maxDepth = depth\n                self.result = root.val\n            return\n        if root.left:\n            depth += 1\n            self.traversal(root.left, depth)\n            depth -= 1\n        if root.right:\n            depth += 1\n            self.traversal(root.right, depth)\n            depth -= 1\n        \n    def findBottomLeftValue(self, root: Optional&#91;TreeNode]) -> int:\n        self.maxDepth = float('-inf')\n        self.result = 0\n        self.traversal(root, 0)\n        return self.result<\/code><\/pre>\n\n\n\n<h1 class=\"wp-block-heading\">112.\u8def\u5f84\u603b\u548c<\/h1>\n\n\n\n<p>\u9898\u76ee\u94fe\u63a5\uff1a<a href=\"https:\/\/leetcode.cn\/problems\/path-sum\/\">112. \u8def\u5f84\u603b\u548c<\/a><\/p>\n\n\n\n<p>\u9898\u76ee\u63cf\u8ff0\uff1a<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>\u7ed9\u4f60\u4e8c\u53c9\u6811\u7684\u6839\u8282\u70b9 <code>root<\/code> \u548c\u4e00\u4e2a\u8868\u793a\u76ee\u6807\u548c\u7684\u6574\u6570 <code>targetSum<\/code> \u3002\u5224\u65ad\u8be5\u6811\u4e2d\u662f\u5426\u5b58\u5728 <strong>\u6839\u8282\u70b9\u5230\u53f6\u5b50\u8282\u70b9<\/strong> \u7684\u8def\u5f84\uff0c\u8fd9\u6761\u8def\u5f84\u4e0a\u6240\u6709\u8282\u70b9\u503c\u76f8\u52a0\u7b49\u4e8e\u76ee\u6807\u548c <code>targetSum<\/code> \u3002\u5982\u679c\u5b58\u5728\uff0c\u8fd4\u56de <code>true<\/code> \uff1b\u5426\u5219\uff0c\u8fd4\u56de <code>false<\/code> \u3002<\/p>\n\n\n\n<p><strong>\u53f6\u5b50\u8282\u70b9<\/strong> \u662f\u6307\u6ca1\u6709\u5b50\u8282\u70b9\u7684\u8282\u70b9\u3002<\/p>\n<\/blockquote>\n\n\n\n<h2 class=\"wp-block-heading\">\u601d\u8def<\/h2>\n\n\n\n<p>\u8fd9\u9053\u9898\u9700\u8981\u4f7f\u7528\u5230\u4e00\u4e9b\u56de\u6eaf\u7684\u6280\u5de7\uff0c\u5728\u521d\u89c1\u65f6\u8fd8\u6ca1\u64cd\u4f5c\u56de\u6eaf\u7684\u7ecf\u9a8c\uff0c\u5f53\u65f6\u89c9\u5f97\u5f88\u96be\u7406\u89e3\u3002<\/p>\n\n\n\n<p>\u8fd9\u8fb9\u4e3b\u8981\u4ecb\u7ecd\u9012\u5f52\u6cd5\u7684\u601d\u8def\uff1a<\/p>\n\n\n\n<p>\u5224\u65ad\u8def\u5f84\u603b\u548c\uff0c\u6211\u4eec\u4f7f\u7528\u6df1\u5ea6\u4f18\u5148\u904d\u5386\uff0c\u63a5\u4e0b\u6765\u662f\u9012\u5f52\u4e09\u90e8\u66f2\uff1a<\/p>\n\n\n\n<p><strong>1.\u786e\u5b9a\u9012\u5f52\u51fd\u6570\u7684\u53c2\u6570\u548c\u8fd4\u56de\u7c7b\u578b<\/strong><\/p>\n\n\n\n<p>\u53c2\u6570\u4e3b\u8981\u662f\u6839\u8282\u70b9\u548c\u9700\u8981\u7684\u76ee\u6807\u6570\u503c\uff0c\u53e6\u5916\u6211\u52a0\u4e86\u4e00\u4e2asumnow\u53c2\u6570\u6765\u8bb0\u5f55\u76ee\u524d\u7684\u603b\u548c<\/p>\n\n\n\n<p>\u8fd4\u56de\u7c7b\u578b\u662f\u5e03\u5c14\u503c\uff0c\u8fd4\u56de\u662f\u5426\u7b26\u5408\u6761\u4ef6<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>def backtracing(self, root, targetSum, sumnow):<\/code><\/pre>\n\n\n\n<p><strong>2.\u786e\u5b9a\u7ec8\u6b62\u6761\u4ef6<\/strong><\/p>\n\n\n\n<p>\u5982\u679c\u904d\u5386\u5230\u53f6\u5b50\u8282\u70b9\uff0c\u5e76\u4e14sumnow\u4e0etargetSum\u503c\u76f8\u7b49\uff0c\u90a3\u4e48\u8bf4\u660e\u7b26\u5408\u6761\u4ef6\u8fd4\u56deTrue\uff0c\u5426\u5219\u8fd4\u56deFalse\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>if root.left == None and root.right == None and sumnow == targetSum:\n    return True\nif root.left == None and root.right == None:\n    return False<\/code><\/pre>\n\n\n\n<p><strong>3.\u786e\u5b9a\u5355\u5c42\u5faa\u73af\u903b\u8f91<\/strong><\/p>\n\n\n\n<p>\u8fd9\u8fb9\u9700\u8981\u5229\u7528\u5230\u56de\u6eaf\u7684\u601d\u60f3\uff0c\u6bcf\u6b21\u5904\u7406\u5b8c\u540e\u51cf\u53bb\u65b0\u52a0\u7684\u503c\u518d\u53bb\u904d\u5386\u65b0\u7684\u8def\u5f84<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>if root.left:\n    sumnow += root.left.val\n    if self.backtracing(root.left, targetSum, sumnow):\n        return True\n    sumnow -= root.left.val\nif root.right:\n    sumnow += root.right.val\n    if self.backtracing(root.right, targetSum, sumnow):\n        return True\n    sumnow -= root.right.val<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u6574\u4f53\u5b9e\u73b0\u5199\u6cd5<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code># Definition for a binary tree node.\n# class TreeNode:\n#     def __init__(self, val=0, left=None, right=None):\n#         self.val = val\n#         self.left = left\n#         self.right = right\nclass Solution:\n    def backtracing(self, root, targetSum, sumnow):\n        if root.left == None and root.right == None and sumnow == targetSum:\n            return True\n        if root.left == None and root.right == None:\n            return False\n        if root.left:\n            sumnow += root.left.val\n            if self.backtracing(root.left, targetSum, sumnow):\n                return True\n            sumnow -= root.left.val\n        if root.right:\n            sumnow += root.right.val\n            if self.backtracing(root.right, targetSum, sumnow):\n                return True\n            sumnow -= root.right.val\n        return False\n    def hasPathSum(self, root: Optional&#91;TreeNode], targetSum: int) -> bool:\n        if not root:\n            return False\n        return self.backtracing(root, targetSum, root.val)<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u62d3\u5c55\u9898\uff1a113.\u8def\u5f84\u603b\u548cii<\/h2>\n\n\n\n<p>\u9898\u76ee\u94fe\u63a5\uff1a<a href=\"https:\/\/leetcode.cn\/problems\/path-sum-ii\/\">113. \u8def\u5f84\u603b\u548c II<\/a><\/p>\n\n\n\n<p>\u9898\u76ee\u63cf\u8ff0\uff1a<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>\u7ed9\u4f60\u4e8c\u53c9\u6811\u7684\u6839\u8282\u70b9 <code>root<\/code> \u548c\u4e00\u4e2a\u6574\u6570\u76ee\u6807\u548c <code>targetSum<\/code> \uff0c\u627e\u51fa\u6240\u6709 <strong>\u4ece\u6839\u8282\u70b9\u5230\u53f6\u5b50\u8282\u70b9<\/strong> \u8def\u5f84\u603b\u548c\u7b49\u4e8e\u7ed9\u5b9a\u76ee\u6807\u548c\u7684\u8def\u5f84\u3002<\/p>\n\n\n\n<p><strong>\u53f6\u5b50\u8282\u70b9<\/strong> \u662f\u6307\u6ca1\u6709\u5b50\u8282\u70b9\u7684\u8282\u70b9\u3002<\/p>\n<\/blockquote>\n\n\n\n<p>\u8fd9\u9053\u9898\u548c\u4e0a\u4e00\u9053\u6ca1\u5565\u533a\u522b\uff0c\u552f\u4e00\u533a\u522b\u5c31\u662f\u4e0a\u4e00\u9053\u5224\u65ad\u662f\u5426\u6709\u8def\u5f84\uff0c\u8fd9\u9053\u9898\u8f93\u51fa\u8def\u5f84\uff0c\u4e0b\u9762\u76f4\u63a5\u7ed9\u51fa\u5199\u6cd5\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Definition for a binary tree node.\n# class TreeNode:\n#     def __init__(self, val=0, left=None, right=None):\n#         self.val = val\n#         self.left = left\n#         self.right = right\nclass Solution:\n    def backtracing(self, root, targetSum, sumnow, path, result):\n        if root.left == None and root.right == None and sumnow == targetSum:\n            result.append(path&#91;:])\n            return result\n        if root.left:\n            sumnow += root.left.val\n            path.append(root.left.val)\n            self.backtracing(root.left, targetSum, sumnow, path, result)\n            path.pop()\n            sumnow -= root.left.val\n        if root.right:\n            sumnow += root.right.val\n            path.append(root.right.val)\n            self.backtracing(root.right, targetSum, sumnow, path, result)\n            path.pop()   \n            sumnow -= root.right.val\n        \n\n    def pathSum(self, root: Optional&#91;TreeNode], targetSum: int) -> List&#91;List&#91;int]]:\n        if not root:\n            return &#91;]\n        result = &#91;]\n        self.backtracing(root, targetSum, root.val, &#91;root.val], result)\n        return result<\/code><\/pre>\n\n\n\n<h1 class=\"wp-block-heading\">106.\u4ece\u4e2d\u5e8f\u4e0e\u540e\u5e8f\u904d\u5386\u5e8f\u5217\u6784\u9020\u4e8c\u53c9\u6811<\/h1>\n\n\n\n<p>\u9898\u76ee\u94fe\u63a5\uff1a<a href=\"https:\/\/leetcode.cn\/problems\/construct-binary-tree-from-inorder-and-postorder-traversal\/\">106. \u4ece\u4e2d\u5e8f\u4e0e\u540e\u5e8f\u904d\u5386\u5e8f\u5217\u6784\u9020\u4e8c\u53c9\u6811<\/a><\/p>\n\n\n\n<p>\u9898\u76ee\u63cf\u8ff0\uff1a<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>\u7ed9\u5b9a\u4e24\u4e2a\u6574\u6570\u6570\u7ec4 <code>inorder<\/code> \u548c <code>postorder<\/code> \uff0c\u5176\u4e2d <code>inorder<\/code> \u662f\u4e8c\u53c9\u6811\u7684\u4e2d\u5e8f\u904d\u5386\uff0c <code>postorder<\/code> \u662f\u540c\u4e00\u68f5\u6811\u7684\u540e\u5e8f\u904d\u5386\uff0c\u8bf7\u4f60\u6784\u9020\u5e76\u8fd4\u56de\u8fd9\u9897 <em>\u4e8c\u53c9\u6811<\/em> \u3002<\/p>\n<\/blockquote>\n\n\n\n<h2 class=\"wp-block-heading\">\u601d\u8def<\/h2>\n\n\n\n<p>\u6784\u9020\u4e8c\u53c9\u6811\u8fd8\u662f\u6bd4\u8f83\u5bb9\u6613\u7684\uff0c\u6211\u4eec\u9700\u8981\u6293\u4f4f\u4e00\u4e2a\u8981\u7d20\uff1a\u540e\u5e8f\u904d\u5386\u6700\u540e\u4e00\u4e2a\u5143\u7d20\u662f\u6839\u8282\u70b9\u3001\u524d\u5e8f\u904d\u5386\u7b2c\u4e00\u4e2a\u5143\u7d20\u662f\u6839\u8282\u70b9\u3002<\/p>\n\n\n\n<p>\u5982\u679c\u77e5\u9053\u54ea\u4e2a\u5143\u7d20\u662f\u6839\u8282\u70b9\uff0c\u90a3\u4e48\u4e0b\u4e00\u6b65\u5c31\u662f\u5bf9\u4e2d\u5e8f\u904d\u5386\u8fdb\u884c\u5206\u6790\uff0c\u4e2d\u5e8f\u904d\u5386\u4e2d\u6839\u8282\u70b9\u5de6\u8fb9\u7684\u662f\u5de6\u5b50\u6811\uff0c\u53f3\u8fb9\u7684\u662f\u53f3\u5b50\u6811\u3002<\/p>\n\n\n\n<p>\u7531\u6b64\u5206\u5272\u51fa\u5de6\u53f3\u5b50\u6811\u540e\uff0c\u6211\u4eec\u53c8\u53ef\u4ee5\u6839\u636e\u5206\u5272\u5b8c\u7684\u4e2d\u5e8f\u904d\u5386\u4e0e\u540e\u7eed\u904d\u5386\u8fdb\u884c\u5b50\u6811\u7684\u6839\u8282\u70b9\u67e5\u627e\u5e76\u91cd\u590d\u4e4b\u524d\u7684\u64cd\u4f5c\uff0c\u6700\u7ec8\u5c31\u80fd\u628a\u6574\u68f5\u6811\u6784\u5efa\u51fa\u4e86\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u5b9e\u73b0\u5199\u6cd5<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code># Definition for a binary tree node.\n# class TreeNode:\n#     def __init__(self, val=0, left=None, right=None):\n#         self.val = val\n#         self.left = left\n#         self.right = right\nclass Solution:\n    def buildTree(self, inorder: List&#91;int], postorder: List&#91;int]) -> Optional&#91;TreeNode]:\n        if not postorder:\n            return \n        \n        root_val = postorder&#91;-1]\n        root = TreeNode(root_val)\n\n        cut_idx = inorder.index(root_val)\n\n        inorder_left = inorder&#91;:cut_idx]\n        inorder_right = inorder&#91;cut_idx + 1:]\n\n        postorder_left = postorder&#91;:len(inorder_left)]\n        postorder_right = postorder&#91;len(inorder_left): len(postorder) - 1]\n\n        root.left = self.buildTree(inorder_left, postorder_left)\n        root.right = self.buildTree(inorder_right, postorder_right)\n        return root<\/code><\/pre>\n\n\n\n<h1 class=\"wp-block-heading\">\u603b\u7ed3<\/h1>\n\n\n\n<p>\u8fd9\u4e00\u5929\u7684\u9898\u76ee\u603b\u4f53\u6765\u8bf4\u8fd8\u662f\u633a\u6709\u610f\u601d\u7684\uff0c\u9694\u4e86\u516b\u5929\u91cd\u65b0\u56de\u987e\u53d1\u73b0\u4e5f\u80fd\u5f88\u5feb\u5c31\u5f97\u5230\u601d\u8def\u3002<\/p>\n\n\n\n<p>\u9664\u6b64\u4ee5\u5916\uff0c\u521d\u6b21\u505a112\u65f6\u8fd8\u6ca1\u6709\u5b66\u4e60\u56de\u6eaf\uff0c\u5f53\u65f6\u7406\u89e3\u5f97\u5f88\u6a21\u7cca\uff0c\u5728\u5b66\u4e60\u4e4b\u540e\u5f88\u5feb\u5c31\u80fd\u7406\u89e3\u5230\u7cbe\u9ad3\u6240\u5728\u4ece\u800c\u8f7b\u677eAC\uff0c\u975e\u5e38\u76f4\u89c2\u5730\u611f\u53d7\u5230\u4e86\u5b66\u4e60\u7684\u6210\u6548\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u524d\u8a00 \u4eca\u5929\u662f\u7b97\u6cd5\u8bad\u7ec3\u8425\u7684\u7b2c\u5341\u516d\u5929\uff1f\u5b9e\u5219\u5e76\u975e\uff0c\u4e2d\u95f4\u7a7a\u4e86\u9760\u8fd18\u7bc7\u7684\u603b\u7ed3\u6ca1\u5199\uff0c\u5149\u505a\u9898\u4e0d\u5199\u603b\u7ed3\u6548\u679c\u5dee\u7684\u79bb\u8c31\u3002\u7ec8\u4e8e\uff0c\u5fd9\u788c [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[13,15,14],"class_list":["post-443","post","type-post","status-publish","format-standard","hentry","category-python","tag-python","tag-15","tag-14"],"_links":{"self":[{"href":"https:\/\/jdoxk3.cn\/index.php\/wp-json\/wp\/v2\/posts\/443","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jdoxk3.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jdoxk3.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jdoxk3.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jdoxk3.cn\/index.php\/wp-json\/wp\/v2\/comments?post=443"}],"version-history":[{"count":2,"href":"https:\/\/jdoxk3.cn\/index.php\/wp-json\/wp\/v2\/posts\/443\/revisions"}],"predecessor-version":[{"id":445,"href":"https:\/\/jdoxk3.cn\/index.php\/wp-json\/wp\/v2\/posts\/443\/revisions\/445"}],"wp:attachment":[{"href":"https:\/\/jdoxk3.cn\/index.php\/wp-json\/wp\/v2\/media?parent=443"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jdoxk3.cn\/index.php\/wp-json\/wp\/v2\/categories?post=443"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jdoxk3.cn\/index.php\/wp-json\/wp\/v2\/tags?post=443"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}