{"id":49330,"date":"2024-12-02T12:05:45","date_gmt":"2024-12-02T04:05:45","guid":{"rendered":"https:\/\/fwq.ai\/blog\/49330\/"},"modified":"2024-12-02T12:05:45","modified_gmt":"2024-12-02T04:05:45","slug":"%e4%ba%8c%e5%8f%89%e6%a0%91%e5%90%8e%e5%ba%8f%e9%81%8d%e5%8e%86","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/49330\/","title":{"rendered":"\u4e8c\u53c9\u6811\u540e\u5e8f\u904d\u5386"},"content":{"rendered":"<p><b><\/b> <\/p>\n<h1>\u4e8c\u53c9\u6811\u540e\u5e8f\u904d\u5386<\/h1>\n<p><span style=\"cursor: pointer\"><i><\/i>\u6536\u85cf<\/span> <\/p>\n<p>\u6700\u8fd1\u53d1\u73b0\u4e0d\u5c11\u5c0f\u4f19\u4f34\u90fd\u5bf9<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u6587\u7ae0<\/span>\u5f88\u611f\u5174\u8da3\uff0c\u6240\u4ee5\u4eca\u5929\u7ee7\u7eed\u7ed9\u5927\u5bb6\u4ecb\u7ecd<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u6587\u7ae0<\/span>\u76f8\u5173\u7684\u77e5\u8bc6\uff0c\u672c\u6587<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u300a\u4e8c\u53c9\u6811\u540e\u5e8f\u904d\u5386\u300b<\/span>\u4e3b\u8981\u5185\u5bb9\u6d89\u53ca\u5230<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\"><\/span>\u7b49\u7b49\u77e5\u8bc6\u70b9\uff0c\u5e0c\u671b\u80fd\u5e2e\u5230\u4f60\uff01\u5f53\u7136\u5982\u679c\u9605\u8bfb\u672c\u6587\u65f6\u5b58\u5728\u4e0d\u540c\u60f3\u6cd5\uff0c\u53ef\u4ee5\u5728\u8bc4\u8bba\u4e2d\u8868\u8fbe\uff0c\u4f46\u662f\u8bf7\u52ff\u4f7f\u7528\u8fc7\u6fc0\u7684\u63aa\u8f9e~<\/p>\n<p>145\u3002\u4e8c\u53c9\u6811\u540e\u5e8f\u904d\u5386<\/p>\n<p><strong>\u96be\u5ea6\uff1a<\/strong>\u7b80\u5355<\/p>\n<p><strong>\u4e3b\u9898\uff1a<\/strong> \u5806\u6808\u3001\u6811\u3001\u6df1\u5ea6\u4f18\u5148\u641c\u7d22\u3001\u4e8c\u53c9\u6811<\/p>\n<p>\u7ed9\u5b9a\u4e8c\u53c9\u6811\u7684\u6839\uff0c\u8fd4\u56de<em>\u5176\u8282\u70b9\u503c\u7684\u540e\u5e8f\u904d\u5386<\/em>.<\/p>\n<p><strong>\u793a\u4f8b1\uff1a<\/strong><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241129\/17328684256749794943945.jpg\" class=\"aligncenter\" title=\"\u4e8c\u53c9\u6811\u540e\u5e8f\u904d\u5386\u63d2\u56fe\" alt=\"\u4e8c\u53c9\u6811\u540e\u5e8f\u904d\u5386\u63d2\u56fe\" \/><\/p>\n<ul>\n<li> <strong>\u8f93\u5165\uff1a<\/strong> root = [1,null,2,3]<\/li>\n<li> <strong>\u8f93\u51fa\uff1a<\/strong> [3,2,1]<\/li>\n<\/ul>\n<p><strong>\u793a\u4f8b2\uff1a<\/strong><\/p>\n<ul>\n<li> <strong>\u8f93\u5165\uff1a<\/strong> root = []<\/li>\n<li> <strong>\u8f93\u51fa\uff1a<\/strong> []<\/li>\n<\/ul>\n<p><strong>\u793a\u4f8b3\uff1a<\/strong><\/p>\n<ul>\n<li> <strong>\u8f93\u5165\uff1a<\/strong> root = [1]<\/li>\n<li> <strong>\u8f93\u51fa\uff1a<\/strong> [1]<\/li>\n<\/ul>\n<p><strong>\u9650\u5236\uff1a<\/strong><\/p>\n<ul>\n<li>\u6811\u4e2d\u8282\u70b9\u7684\u6570\u91cf\u5728 [0, 100] \u8303\u56f4\u5185\u3002<\/li>\n<li>-100 &lt;= node.val &lt;= 100<\/li>\n<\/ul>\n<p><strong>\u89e3\u51b3\u65b9\u6848\uff1a<\/strong><\/p>\n<p>\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u5806\u6808\u7684\u8fed\u4ee3\u65b9\u6cd5\u3002\u540e\u5e8f\u904d\u5386\u9075\u5faa\u4ee5\u4e0b\u987a\u5e8f\uff1a\u5de6\u3001\u53f3\u3001\u6839\u3002<\/p>\n<p>\u8ba9\u6211\u4eec\u7528 php \u5b9e\u73b0\u8fd9\u4e2a\u89e3\u51b3\u65b9\u6848\uff1a<strong>145\u3002\u4e8c\u53c9\u6811\u540e\u5e8f\u904d\u5386<\/strong><\/p>\n<pre>&lt;?php\n\/\/ Definition for a binary tree node.\nclass TreeNode {\n    public $val = null;\n    public $left = null;\n    public $right = null;\n    public function __construct($val = 0, $left = null, $right = null) {\n        $this-&gt;val = $val;\n        $this-&gt;left = $left;\n        $this-&gt;right = $right;\n    }\n}\n\/**\n* @param TreeNode $root\n* @return Integer[]\n*\/\nfunction postorderTraversal($root) {\n    ...\n    ...\n    ...\n    \/**\n     * go to .\/solution.php\n     *\/\n}\n\n\/\/ Example usage:\n\n\/\/ Example 1\n$root1 = new TreeNode(1);\n$root1-&gt;right = new TreeNode(2);\n$root1-&gt;right-&gt;left = new TreeNode(3);\nprint_r(postorderTraversal($root1)); \/\/ Output: [3, 2, 1]\n\n\/\/ Example 2\n$root2 = null;\nprint_r(postorderTraversal($root2)); \/\/ Output: []\n\n\/\/ Example 3\n$root3 = new TreeNode(1);\nprint_r(postorderTraversal($root3)); \/\/ Output: [1]\n?&gt;\n<\/pre>\n<h3> \u89e3\u91ca\uff1a <\/h3>\n<ul>\n<li>\n<p><strong>treenode \u7c7b\uff1a<\/strong> treenode \u7c7b\u5b9a\u4e49\u4e8c\u53c9\u6811\u4e2d\u7684\u8282\u70b9\uff0c\u5305\u62ec\u5176\u503c\u3001\u5de6\u5b50\u8282\u70b9\u548c\u53f3\u5b50\u8282\u70b9\u3002<\/p>\n<\/li>\n<li>\n<p><strong>postorder\u904d\u5386\u51fd\u6570\uff1a<\/strong><\/p>\n<ul>\n<li>\u6211\u4eec\u521d\u59cb\u5316\u4e00\u4e2a\u7a7a\u7684\u7ed3\u679c\u6570\u7ec4\u548c\u4e00\u4e2a\u5806\u6808\u3002<\/li>\n<li>\u6211\u4eec\u4f7f\u7528 while \u5faa\u73af\uff0c\u53ea\u8981\u5806\u6808\u4e0d\u4e3a\u7a7a\u6216\u5f53\u524d\u8282\u70b9\u4e0d\u4e3a\u7a7a\uff0c\u8be5\u5faa\u73af\u5c31\u4f1a\u7ee7\u7eed\u3002<\/li>\n<li>\u5982\u679c\u5f53\u524d\u8282\u70b9\u4e0d\u4e3a\u7a7a\uff0c\u6211\u4eec\u5c06\u5176\u538b\u5165\u5806\u6808\u5e76\u79fb\u52a8\u5230\u5176\u5de6\u5b50\u8282\u70b9\u3002<\/li>\n<li>\u5982\u679c\u5f53\u524d\u8282\u70b9\u4e3a\u7a7a\uff0c\u6211\u4eec\u68c0\u67e5\u6808\u9876\u8282\u70b9\u3002\u5982\u679c\u5b83\u6709\u4e00\u4e2a\u6211\u4eec\u8fd8\u6ca1\u6709\u8bbf\u95ee\u8fc7\u7684\u53f3\u5b69\u5b50\uff0c\u6211\u4eec\u5c31\u4f1a\u79fb\u52a8\u5230\u53f3\u5b69\u5b50\u3002\u5426\u5219\uff0c\u6211\u4eec\u5c06\u8282\u70b9\u7684\u503c\u6dfb\u52a0\u5230\u7ed3\u679c\u6570\u7ec4\u4e2d\u5e76\u5c06\u5176\u4ece\u5806\u6808\u4e2d\u5f39\u51fa\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>\u8fd9\u79cd\u8fed\u4ee3\u65b9\u6cd5\u6a21\u62df\u4e86\u9012\u5f52\u540e\u5e8f\u904d\u5386\uff0c\u800c\u4e0d\u4f7f\u7528\u7cfb\u7edf\u9012\u5f52\uff0c\u4ece\u800c\u66f4\u52a0\u8282\u7701\u5185\u5b58\u3002<\/p>\n<p><strong>\u8054\u7cfb\u94fe\u63a5<\/strong><\/p>\n<p>\u5982\u679c\u60a8\u53d1\u73b0\u672c\u7cfb\u5217\u6709\u5e2e\u52a9\uff0c\u8bf7\u8003\u8651\u5728 github \u4e0a\u7ed9<strong>\u5b58\u50a8\u5e93<\/strong> \u4e00\u9897\u661f\uff0c\u6216\u5728\u60a8\u6700\u559c\u6b22\u7684\u793e\u4ea4\u7f51\u7edc\u4e0a\u5206\u4eab\u8be5\u5e16\u5b50?\u3002\u60a8\u7684\u652f\u6301\u5bf9\u6211\u6765\u8bf4\u610f\u4e49\u91cd\u5927\uff01<\/p>\n<p>\u5982\u679c\u60a8\u60f3\u8981\u66f4\u591a\u7c7b\u4f3c\u7684\u6709\u7528\u5185\u5bb9\uff0c\u8bf7\u968f\u65f6\u5173\u6ce8\u6211\uff1a<\/p>\n<ul>\n<li><strong>\u9886\u82f1<\/strong><\/li>\n<li><strong>github<\/strong><\/li>\n<\/ul>\n<p>\u4eca\u5929\u5173\u4e8e\u300a\u4e8c\u53c9\u6811\u540e\u5e8f\u904d\u5386\u300b\u7684\u5185\u5bb9\u5c31\u4ecb\u7ecd\u5230\u8fd9\u91cc\u4e86\uff0c\u662f\u4e0d\u662f\u5b66\u8d77\u6765\u4e00\u76ee\u4e86\u7136\uff01\u60f3\u8981\u4e86\u89e3\u66f4\u591a\u5173\u4e8e\u7684\u5185\u5bb9\u8bf7\u5173\u6ce8\u7c73\u4e91\u516c\u4f17\u53f7\uff01<\/p>\n<p> \u7248\u672c\u58f0\u660e \u672c\u6587\u8f6c\u8f7d\u4e8e\uff1adev.to \u5982\u6709\u4fb5\u72af\uff0c\u8bf7\u8054\u7cfb \u5220\u9664<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e8c\u53c9\u6811\u540e\u5e8f\u904d\u5386 \u6536\u85cf \u6700\u8fd1\u53d1\u73b0\u4e0d\u5c11\u5c0f\u4f19\u4f34\u90fd\u5bf9\u6587\u7ae0\u5f88\u611f\u5174\u8da3\uff0c\u6240\u4ee5\u4eca\u5929\u7ee7\u7eed\u7ed9\u5927\u5bb6\u4ecb\u7ecd\u6587\u7ae0\u76f8\u5173\u7684\u77e5\u8bc6\uff0c\u672c\u6587\u300a\u4e8c\u53c9\u6811\u540e\u5e8f\u904d\u5386\u300b\u4e3b\u8981\u5185\u5bb9\u6d89\u53ca\u5230\u7b49\u7b49\u77e5\u8bc6\u70b9\uff0c\u5e0c\u671b\u80fd\u5e2e\u5230\u4f60\uff01\u5f53\u7136\u5982\u679c\u9605\u8bfb\u672c\u6587\u65f6\u5b58\u5728\u4e0d\u540c\u60f3\u6cd5\uff0c\u53ef\u4ee5\u5728\u8bc4\u8bba\u4e2d\u8868\u8fbe\uff0c\u4f46\u662f\u8bf7\u52ff\u4f7f\u7528\u8fc7\u6fc0\u7684\u63aa\u8f9e~ 145\u3002\u4e8c\u53c9\u6811\u540e\u5e8f\u904d\u5386 \u96be\u5ea6\uff1a\u7b80\u5355 \u4e3b\u9898\uff1a \u5806\u6808\u3001\u6811\u3001\u6df1\u5ea6\u4f18\u5148\u641c\u7d22\u3001\u4e8c\u53c9\u6811 \u7ed9\u5b9a\u4e8c\u53c9\u6811\u7684\u6839\uff0c\u8fd4\u56de\u5176\u8282\u70b9\u503c\u7684\u540e\u5e8f\u904d\u5386. \u793a\u4f8b1\uff1a \u8f93\u5165\uff1a root = [1,null,2,3] \u8f93\u51fa\uff1a [3,2,1] \u793a\u4f8b2\uff1a \u8f93\u5165\uff1a root = [] \u8f93\u51fa\uff1a [] \u793a\u4f8b3\uff1a \u8f93\u5165\uff1a root = [1] \u8f93\u51fa\uff1a [1] \u9650\u5236\uff1a \u6811\u4e2d\u8282\u70b9\u7684\u6570\u91cf\u5728 [0, 100] \u8303\u56f4\u5185\u3002 -100 &lt;= node.val &lt;= 100 \u89e3\u51b3\u65b9\u6848\uff1a \u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u5806\u6808\u7684\u8fed\u4ee3\u65b9\u6cd5\u3002\u540e\u5e8f\u904d\u5386\u9075\u5faa\u4ee5\u4e0b\u987a\u5e8f\uff1a\u5de6\u3001\u53f3\u3001\u6839\u3002 \u8ba9\u6211\u4eec\u7528 php \u5b9e\u73b0\u8fd9\u4e2a\u89e3\u51b3\u65b9\u6848\uff1a145\u3002\u4e8c\u53c9\u6811\u540e\u5e8f\u904d\u5386 &lt;?php \/\/ Definition for a binary tree node. class TreeNode { [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-49330","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/49330","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=49330"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/49330\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=49330"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=49330"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=49330"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}