{"id":2584,"date":"2022-02-04T11:22:43","date_gmt":"2022-02-04T03:22:43","guid":{"rendered":"http:\/\/139.9.1.231\/?p=2584"},"modified":"2022-02-04T11:22:45","modified_gmt":"2022-02-04T03:22:45","slug":"leetcodeday109","status":"publish","type":"post","link":"http:\/\/139.9.1.231\/index.php\/2022\/02\/04\/leetcodeday109\/","title":{"rendered":"leetcodeday109 &#8211;\u6709\u5e8f\u94fe\u8868\u8f6c\u6362\u4e8c\u53c9\u641c\u7d22\u6811"},"content":{"rendered":"\n<p>\u7ed9\u5b9a\u4e00\u4e2a\u5355\u94fe\u8868\uff0c\u5176\u4e2d\u7684\u5143\u7d20\u6309\u5347\u5e8f\u6392\u5e8f\uff0c\u5c06\u5176\u8f6c\u6362\u4e3a\u9ad8\u5ea6\u5e73\u8861\u7684\u4e8c\u53c9\u641c\u7d22\u6811\u3002<\/p>\n\n\n\n<p>\u672c\u9898\u4e2d\uff0c\u4e00\u4e2a\u9ad8\u5ea6\u5e73\u8861\u4e8c\u53c9\u6811\u662f\u6307\u4e00\u4e2a\u4e8c\u53c9\u6811<em>\u6bcf\u4e2a\u8282\u70b9&nbsp;<\/em>\u7684\u5de6\u53f3\u4e24\u4e2a\u5b50\u6811\u7684\u9ad8\u5ea6\u5dee\u7684\u7edd\u5bf9\u503c\u4e0d\u8d85\u8fc7 1\u3002<\/p>\n\n\n\n<p><strong>\u793a\u4f8b:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\u7ed9\u5b9a\u7684\u6709\u5e8f\u94fe\u8868\uff1a &#91;-10, -3, 0, 5, 9],\n\n\u4e00\u4e2a\u53ef\u80fd\u7684\u7b54\u6848\u662f\uff1a&#91;0, -3, 9, -10, null, 5], \u5b83\u53ef\u4ee5\u8868\u793a\u4e0b\u9762\u8fd9\u4e2a\u9ad8\u5ea6\u5e73\u8861\u4e8c\u53c9\u641c\u7d22\u6811\uff1a\n\n      0\n     \/ \\\n   -3   9\n   \/   \/\n -10  5<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code># @lc app=leetcode.cn id=109 lang=python3\r\n#\r\n# &#91;109] \u6709\u5e8f\u94fe\u8868\u8f6c\u6362\u4e8c\u53c9\u641c\u7d22\u6811\r\n#\r\n\r\n# @lc code=start\r\n# Definition for singly-linked list.\r\n# class ListNode:\r\n#     def __init__(self, val=0, next=None):\r\n#         self.val = val\r\n#         self.next = next\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 sortedListToBST(self, head: Optional&#91;ListNode]) -> Optional&#91;TreeNode]:\r\n        nums=&#91;]\r\n        while head!=None:\r\n            nums.append(head.val)\r\n            head=head.next\r\n        lens=len(nums)\r\n        if lens==0:\r\n            return None\r\n        def sorted(nums):\r\n            if not nums: \r\n                return None\r\n            lens=len(nums)\r\n            mid=lens\/\/2\r\n            root=TreeNode(nums&#91;mid])\r\n            root.left=sorted(nums&#91;:mid])\r\n            root.right=sorted(nums&#91;mid+1:])\r\n            return root\r\n        return sorted(nums)\r\n# @lc code=end\r\n\r\n<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full is-style-default\"><img loading=\"lazy\" width=\"838\" height=\"282\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/02\/image-27.png\" alt=\"\" class=\"wp-image-2585\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/02\/image-27.png 838w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/02\/image-27-300x101.png 300w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/02\/image-27-768x258.png 768w\" sizes=\"(max-width: 838px) 100vw, 838px\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>\u7ed9\u5b9a\u4e00\u4e2a\u5355\u94fe\u8868\uff0c\u5176\u4e2d\u7684\u5143\u7d20\u6309\u5347\u5e8f\u6392\u5e8f\uff0c\u5c06\u5176\u8f6c\u6362\u4e3a\u9ad8\u5ea6\u5e73\u8861\u7684\u4e8c\u53c9\u641c\u7d22\u6811\u3002 \u672c\u9898\u4e2d\uff0c\u4e00\u4e2a\u9ad8\u5ea6\u5e73\u8861\u4e8c\u53c9\u6811\u662f\u6307\u4e00\u4e2a\u4e8c\u53c9 &hellip; <a href=\"http:\/\/139.9.1.231\/index.php\/2022\/02\/04\/leetcodeday109\/\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">leetcodeday109 &#8211;\u6709\u5e8f\u94fe\u8868\u8f6c\u6362\u4e8c\u53c9\u641c\u7d22\u6811<\/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\/2584"}],"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=2584"}],"version-history":[{"count":1,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/posts\/2584\/revisions"}],"predecessor-version":[{"id":2586,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/posts\/2584\/revisions\/2586"}],"wp:attachment":[{"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/media?parent=2584"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/categories?post=2584"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/tags?post=2584"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}