{"id":131,"date":"2017-08-27T20:29:28","date_gmt":"2017-08-27T12:29:28","guid":{"rendered":"https:\/\/www.ccagml.com\/?p=131"},"modified":"2018-11-27T16:30:49","modified_gmt":"2018-11-27T08:30:49","slug":"104-maximum-depth-of-binary-tree","status":"publish","type":"post","link":"https:\/\/www.ccagml.com\/?p=131","title":{"rendered":"104. Maximum Depth of Binary Tree"},"content":{"rendered":"<p>Given a binary tree, find its maximum depth.<\/p>\n<p>The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.<\/p>\n<p><strong>Note:<\/strong>\u00a0A leaf is a node with no children.<\/p>\n<p><strong>Example:<\/strong><\/p>\n<p>Given binary tree\u00a0<code>[3,9,20,null,null,15,7]<\/code>,<\/p>\n<pre>    3\r\n   \/ \\\r\n  9  20\r\n    \/  \\\r\n   15   7<\/pre>\n<p>return its depth = 3.<\/p>\n<p><strong>Python<\/strong><\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\"> \r\n# Definition for a binary tree node.\r\n# class TreeNode(object):\r\n#     def __init__(self, x):\r\n#         self.val = x\r\n#         self.left = None\r\n#         self.right = None\r\n\r\nclass Solution(object):\r\n    def maxDepth(self, root):\r\n        &quot;&quot;&quot;\r\n        :type root: TreeNode\r\n        :rtype: int\r\n        &quot;&quot;&quot;\r\n        try:\r\n            return max(self.maxDepth(root.left), self.maxDepth(root.right))+1\r\n        except:\r\n            return 0\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Given a binary tree, find its maximum depth. The maximu<a href=\"https:\/\/www.ccagml.com\/?p=131\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">104. Maximum Depth of Binary Tree<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[29,20],"tags":[],"_links":{"self":[{"href":"https:\/\/www.ccagml.com\/index.php?rest_route=\/wp\/v2\/posts\/131"}],"collection":[{"href":"https:\/\/www.ccagml.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ccagml.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ccagml.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ccagml.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=131"}],"version-history":[{"count":1,"href":"https:\/\/www.ccagml.com\/index.php?rest_route=\/wp\/v2\/posts\/131\/revisions"}],"predecessor-version":[{"id":132,"href":"https:\/\/www.ccagml.com\/index.php?rest_route=\/wp\/v2\/posts\/131\/revisions\/132"}],"wp:attachment":[{"href":"https:\/\/www.ccagml.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=131"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ccagml.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=131"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ccagml.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=131"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}