{"id":2483,"date":"2022-01-29T15:40:52","date_gmt":"2022-01-29T07:40:52","guid":{"rendered":"http:\/\/139.9.1.231\/?p=2483"},"modified":"2022-01-29T15:40:53","modified_gmt":"2022-01-29T07:40:53","slug":"leetcodeday111","status":"publish","type":"post","link":"http:\/\/139.9.1.231\/index.php\/2022\/01\/29\/leetcodeday111\/","title":{"rendered":"leetcodeday111 &#8211;\u4e8c\u53c9\u6811\u7684\u6700\u5c0f\u6df1\u5ea6"},"content":{"rendered":"\n<p>\u7ed9\u5b9a\u4e00\u4e2a\u4e8c\u53c9\u6811\uff0c\u627e\u51fa\u5176\u6700\u5c0f\u6df1\u5ea6\u3002<\/p>\n\n\n\n<p>\u6700\u5c0f\u6df1\u5ea6\u662f\u4ece\u6839\u8282\u70b9\u5230\u6700\u8fd1\u53f6\u5b50\u8282\u70b9\u7684\u6700\u77ed\u8def\u5f84\u4e0a\u7684\u8282\u70b9\u6570\u91cf\u3002<\/p>\n\n\n\n<p><strong>\u8bf4\u660e\uff1a<\/strong>\u53f6\u5b50\u8282\u70b9\u662f\u6307\u6ca1\u6709\u5b50\u8282\u70b9\u7684\u8282\u70b9\u3002<\/p>\n\n\n\n<p><strong>\u793a\u4f8b 1\uff1a<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image is-style-default\"><img src=\"https:\/\/assets.leetcode.com\/uploads\/2020\/10\/12\/ex_depth.jpg\" alt=\"\"\/><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>\u8f93\u5165\uff1a<\/strong>root = &#91;3,9,20,null,null,15,7]\n<strong>\u8f93\u51fa\uff1a<\/strong>2<\/code><\/pre>\n\n\n\n<p><strong>\u793a\u4f8b 2\uff1a<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>\u8f93\u5165\uff1a<\/strong>root = &#91;2,null,3,null,4,null,5,null,6]\n<strong>\u8f93\u51fa\uff1a<\/strong>5<\/code><\/pre>\n\n\n\n<p><strong>\u63d0\u793a\uff1a<\/strong><\/p>\n\n\n\n<ul><li>\u6811\u4e2d\u8282\u70b9\u6570\u7684\u8303\u56f4\u5728&nbsp;<code>[0, 10<sup>5<\/sup>]<\/code>&nbsp;\u5185<\/li><li><code>-1000 &lt;= Node.val &lt;= 1000<\/code><\/li><\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code># &#91;111] \u4e8c\u53c9\u6811\u7684\u6700\u5c0f\u6df1\u5ea6\r\n#\r\n\r\n# @lc code=start\r\n# Definition for a binary tree node.\r\n# class TreeNode:\r\n#     def __init__(self, val=0, left=None, right=None):\r\n#         self.val = val\r\n#         self.left = left\r\n#         self.right = right\r\nclass Solution:\r\n    def minDepth(self, root: TreeNode) -> int:\r\n        res=list()\r\n        def subisBalanced(root,deep):\r\n            if root.left!=None:\r\n                deepl=deep+1 \r\n                subisBalanced(root.left,deepl)\r\n            \r\n                \r\n            if  root.right!=None:\r\n                deepr=deep+1 \r\n                subisBalanced(root.right,deepr)\r\n            \r\n            if  root.left==None and root.right==None:\r\n                res.append(deep)\r\n                return \r\n        if root==None:\r\n            return 0\r\n        subisBalanced(root,1)\r\n        return min(res)\r\n# @lc code=end<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full is-style-default\"><img loading=\"lazy\" width=\"876\" height=\"249\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/01\/image-310.png\" alt=\"\" class=\"wp-image-2484\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/01\/image-310.png 876w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/01\/image-310-300x85.png 300w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/01\/image-310-768x218.png 768w\" sizes=\"(max-width: 876px) 100vw, 876px\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>\u7ed9\u5b9a\u4e00\u4e2a\u4e8c\u53c9\u6811\uff0c\u627e\u51fa\u5176\u6700\u5c0f\u6df1\u5ea6\u3002 \u6700\u5c0f\u6df1\u5ea6\u662f\u4ece\u6839\u8282\u70b9\u5230\u6700\u8fd1\u53f6\u5b50\u8282\u70b9\u7684\u6700\u77ed\u8def\u5f84\u4e0a\u7684\u8282\u70b9\u6570\u91cf\u3002 \u8bf4\u660e\uff1a\u53f6\u5b50\u8282\u70b9\u662f\u6307 &hellip; <a href=\"http:\/\/139.9.1.231\/index.php\/2022\/01\/29\/leetcodeday111\/\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">leetcodeday111 &#8211;\u4e8c\u53c9\u6811\u7684\u6700\u5c0f\u6df1\u5ea6<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[6],"tags":[],"_links":{"self":[{"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/posts\/2483"}],"collection":[{"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/comments?post=2483"}],"version-history":[{"count":1,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/posts\/2483\/revisions"}],"predecessor-version":[{"id":2485,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/posts\/2483\/revisions\/2485"}],"wp:attachment":[{"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/media?parent=2483"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/categories?post=2483"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/tags?post=2483"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}