{"id":1778,"date":"2016-02-07T12:09:29","date_gmt":"2016-02-07T04:09:29","guid":{"rendered":"http:\/\/boweihe.me\/?p=1778"},"modified":"2016-02-07T12:09:29","modified_gmt":"2016-02-07T04:09:29","slug":"leetcode-104-maximum-depth-of-binary-tree","status":"publish","type":"post","link":"https:\/\/dayandcarrot.space\/?p=1778","title":{"rendered":"LeetCode #104. Maximum Depth of Binary Tree"},"content":{"rendered":"<p>\u9898\u76ee\uff1a<a href=\"https:\/\/leetcode.com\/problems\/maximum-depth-of-binary-tree\/\" target=\"_blank\" rel=\"noopener noreferrer\">https:\/\/leetcode.com\/problems\/maximum-depth-of-binary-tree\/<\/a><br \/>\n\u601d\u8def\uff1a\u5c31\u662f\u4e2a\u6811\u904d\u5386\u7684\u4e1c\u897f\uff0c\u5f88\u7b80\u5355\u5730\u53ef\u4ee5\u7528\u9012\u5f52\u5b9e\u73b0<br \/>\n\u4ee3\u7801\uff1a<\/p>\n<pre class=\"lang:c++ decode:true  \">\/**\n * Definition for a binary tree node.\n * struct TreeNode {\n *     int val;\n *     TreeNode *left;\n *     TreeNode *right;\n *     TreeNode(int x) : val(x), left(NULL), right(NULL) {}\n * };\n *\/\nclass Solution {\npublic:\n    int maxDepth(TreeNode* root) {\n        \/\/ Left - N - Right\n        if(root == NULL) {\n            return 0;\n        } else {\n            \/\/Non-empty\n            int leftDeep = 1 + maxDepth(root-&gt;left);\n            int rightDeep = 1 + maxDepth(root-&gt;right);\n            if(leftDeep &gt; rightDeep)\n                return leftDeep;\n            else\n                return rightDeep;\n        }\n    }\n};<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u9898\u76ee\uff1ahttps:\/\/leetcode.com\/problems\/maximum-depth-of-binary-tree\/ \u601d\u8def\uff1a\u5c31\u662f\u4e2a\u6811\u904d\u5386\u7684\u4e1c\u897f\uff0c\u5f88\u7b80\u5355\u5730\u53ef\u4ee5\u7528\u9012\u5f52\u5b9e\u73b0 \u4ee3\u7801\uff1a \/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; *\/ class Solution { public: int maxDepth(TreeNode* root) { \/\/ Left &#8211; N &#8211; Right if(root == NULL) { return 0; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[66],"class_list":["post-1778","post","type-post","status-publish","format-standard","hentry","category-study","tag-leetcode-oj"],"_links":{"self":[{"href":"https:\/\/dayandcarrot.space\/index.php?rest_route=\/wp\/v2\/posts\/1778","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dayandcarrot.space\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dayandcarrot.space\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dayandcarrot.space\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dayandcarrot.space\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1778"}],"version-history":[{"count":0,"href":"https:\/\/dayandcarrot.space\/index.php?rest_route=\/wp\/v2\/posts\/1778\/revisions"}],"wp:attachment":[{"href":"https:\/\/dayandcarrot.space\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1778"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dayandcarrot.space\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1778"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dayandcarrot.space\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1778"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}