{"id":2123,"date":"2023-10-04T13:07:56","date_gmt":"2023-10-04T05:07:56","guid":{"rendered":"https:\/\/white-night.club\/?p=2123"},"modified":"2023-11-09T11:07:51","modified_gmt":"2023-11-09T03:07:51","slug":"ad25","status":"publish","type":"post","link":"https:\/\/white-night.club\/index.php\/2023\/10\/04\/ad25\/","title":{"rendered":"876.\u00a0\u94fe\u8868\u7684\u4e2d\u95f4\u7ed3\u70b9"},"content":{"rendered":"\n<p>\u7ed9\u4f60\u5355\u94fe\u8868\u7684\u5934\u7ed3\u70b9\u00a0<code>head<\/code>\u00a0\uff0c\u8bf7\u4f60\u627e\u51fa\u5e76\u8fd4\u56de\u94fe\u8868\u7684\u4e2d\u95f4\u7ed3\u70b9\u3002<\/p>\n\n\n\n<p>\u5982\u679c\u6709\u4e24\u4e2a\u4e2d\u95f4\u7ed3\u70b9\uff0c\u5219\u8fd4\u56de\u7b2c\u4e8c\u4e2a\u4e2d\u95f4\u7ed3\u70b9\u3002<\/p>\n\n\n\n<p><strong>\u793a\u4f8b 1\uff1a<\/strong><img decoding=\"async\" alt=\"\" src=\"https:\/\/assets.leetcode.com\/uploads\/2021\/07\/23\/lc-midlist1.jpg\"><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><strong>\u8f93\u5165\uff1a<\/strong>head = [1,2,3,4,5]\n<strong>\u8f93\u51fa\uff1a<\/strong>[3,4,5]\n<strong>\u89e3\u91ca\uff1a<\/strong>\u94fe\u8868\u53ea\u6709\u4e00\u4e2a\u4e2d\u95f4\u7ed3\u70b9\uff0c\u503c\u4e3a 3 \u3002\n<\/pre>\n\n\n\n<p><strong>\u793a\u4f8b 2\uff1a<\/strong><img decoding=\"async\" alt=\"\" src=\"https:\/\/assets.leetcode.com\/uploads\/2021\/07\/23\/lc-midlist2.jpg\"><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><strong>\u8f93\u5165\uff1a<\/strong>head = [1,2,3,4,5,6]\n<strong>\u8f93\u51fa\uff1a<\/strong>[4,5,6]\n<strong>\u89e3\u91ca\uff1a<\/strong>\u8be5\u94fe\u8868\u6709\u4e24\u4e2a\u4e2d\u95f4\u7ed3\u70b9\uff0c\u503c\u5206\u522b\u4e3a 3 \u548c 4 \uff0c\u8fd4\u56de\u7b2c\u4e8c\u4e2a\u7ed3\u70b9\u3002\n<\/pre>\n\n\n\n<p><strong>\u63d0\u793a\uff1a<\/strong><\/p>\n\n\n\n<ul>\n<li>\u94fe\u8868\u7684\u7ed3\u70b9\u6570\u8303\u56f4\u662f&nbsp;<code>[1, 100]<\/code><\/li>\n\n\n\n<li><code>1 &lt;= Node.val &lt;= 100<\/code><\/li>\n<\/ul>\n\n\n\n<div style=\"height:60px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<blockquote class=\"wp-block-quote has-luminous-vivid-amber-color has-text-color\">\n<p>\u89e3\u9898\u601d\u8def<\/p>\n<cite><em>\u53cc\u6307\u9488<\/em><\/cite><\/blockquote>\n\n\n\n<p>\u8bdd\u662f\u8fd9\u4e48\u8bf4\uff0c\u4f46\u8fd8\u662f\u5148\u7528\u66b4\u529b\u76f4\u63a5\u5199\u770b\u4e00\u4e0b\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/**\r\n * Definition for singly-linked list.\r\n * struct ListNode {\r\n *     int val;\r\n *     ListNode *next;\r\n *     ListNode() : val(0), next(nullptr) {}\r\n *     ListNode(int x) : val(x), next(nullptr) {}\r\n *     ListNode(int x, ListNode *next) : val(x), next(next) {}\r\n * };\r\n *\/\r\nclass Solution {\r\npublic:\r\n    ListNode* middleNode(ListNode* head) {\r\n        ListNode*cur=head;\r\n        int len=0;\r\n        while(cur!=NULL)\r\n        {\r\n            len++;\r\n            cur=cur->next;\r\n        }\r\n        cur=head;\r\n        len\/=2;\r\n        while(len--)\r\n        {\r\n            cur=cur->next;\r\n        }\r\n        return cur;\r\n    }\r\n};<\/code><\/pre>\n\n\n\n<p>\u63a5\u4e0b\u6765\u770b\u770b\u53cc\u6307\u9488\u3002\u5feb\u6307\u9488\u6bcf\u6b21\u8d702\u6b65\uff0c\u6162\u6307\u9488\u6bcf\u6b21\u8d701\u6b65\u3002\u5982\u679c\u603b\u957f\u5ea6len\u4e3a\u5076\u6570\uff0c\u90a3\u5feb\u6307\u9488\u8d70\u5230NULL\u7684\u65f6\u5019\u8d70\u4e86n\/2\u6b21\uff0c\u5171\u8d70\u4e86n\u7684\u8ddd\u79bb\uff1b\u6162\u6307\u9488\u5219\u540c\u6837\u8d70\u4e86n\/2\u6b21\uff0c\u5171\u8d70\u4e86n\/2\u7684\u8ddd\u79bb\u3002\u5982\u679c\u957f\u5ea6len\u4e3a\u5947\u6570\uff0c\u90a3\u5feb\u6307\u9488\u8d70\u5230\u5c3e\u8282\u70b9\u7684\u65f6\u5019\u8d70\u4e86n-1\/2\u6b21\uff0c\u5171\u8d70\u4e86n-1\u7684\u8ddd\u79bb\uff1b\u6162\u6307\u9488\u540c\u6837\u8d70\u4e86n-1\/2\u6b21\uff0c\u5171\u8d70\u4e86n-1\/2\u7684\u8ddd\u79bb\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/**\r\n * Definition for singly-linked list.\r\n * struct ListNode {\r\n *     int val;\r\n *     ListNode *next;\r\n *     ListNode() : val(0), next(nullptr) {}\r\n *     ListNode(int x) : val(x), next(nullptr) {}\r\n *     ListNode(int x, ListNode *next) : val(x), next(next) {}\r\n * };\r\n *\/\r\nclass Solution {\r\npublic:\r\n    ListNode* middleNode(ListNode* head) {\r\n        ListNode*fast=head;\r\n        ListNode*slow=head;\r\n        while(fast!=NULL&amp;&amp;fast->next!=NULL)\r\n        {\r\n            fast=fast->next->next;\r\n            slow=slow->next;\r\n        }\r\n        return slow;\r\n    }\r\n};<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Leetcode\u9898\u76ee\uff1a\u94fe\u8868\u53cc\u6307\u9488<\/p>\n","protected":false},"author":1,"featured_media":2827,"comment_status":"open","ping_status":"","sticky":false,"template":"base","format":"standard","meta":{"footnotes":""},"categories":[42,25],"tags":[38],"_links":{"self":[{"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/posts\/2123"}],"collection":[{"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/comments?post=2123"}],"version-history":[{"count":0,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/posts\/2123\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/media\/2827"}],"wp:attachment":[{"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/media?parent=2123"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/categories?post=2123"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/tags?post=2123"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}