{"id":1247,"date":"2023-05-06T20:48:29","date_gmt":"2023-05-06T12:48:29","guid":{"rendered":"https:\/\/white-night.club\/?p=1247"},"modified":"2023-11-09T11:07:55","modified_gmt":"2023-11-09T03:07:55","slug":"ad12","status":"publish","type":"post","link":"https:\/\/white-night.club\/index.php\/2023\/05\/06\/ad12\/","title":{"rendered":"\u5251\u6307 Offer II 024.\u00a0\u53cd\u8f6c\u94fe\u8868"},"content":{"rendered":"\n<p>\u7ed9\u5b9a\u5355\u94fe\u8868\u7684\u5934\u8282\u70b9&nbsp;<code>head<\/code>&nbsp;\uff0c\u8bf7\u53cd\u8f6c\u94fe\u8868\uff0c\u5e76\u8fd4\u56de\u53cd\u8f6c\u540e\u7684\u94fe\u8868\u7684\u5934\u8282\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\/02\/19\/rev1ex1.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>[5,4,3,2,1]\n<\/pre>\n\n\n\n<p><strong>\u793a\u4f8b 2\uff1a<\/strong><img decoding=\"async\" alt=\"\" src=\"https:\/\/assets.leetcode.com\/uploads\/2021\/02\/19\/rev1ex2.jpg\"><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><strong>\u8f93\u5165\uff1a<\/strong>head = [1,2]\n<strong>\u8f93\u51fa\uff1a<\/strong>[2,1]\n<\/pre>\n\n\n\n<p><strong>\u793a\u4f8b 3\uff1a<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><strong>\u8f93\u5165\uff1a<\/strong>head = []\n<strong>\u8f93\u51fa\uff1a<\/strong>[]\n<\/pre>\n\n\n\n<p><strong>\u63d0\u793a\uff1a<\/strong><\/p>\n\n\n\n<ul>\n<li>\u94fe\u8868\u4e2d\u8282\u70b9\u7684\u6570\u76ee\u8303\u56f4\u662f&nbsp;<code>[0, 5000]<\/code><\/li>\n\n\n\n<li><code>-5000 &lt;= Node.val &lt;= 5000<\/code><\/li>\n<\/ul>\n\n\n\n<p><strong>\u8fdb\u9636\uff1a<\/strong>\u94fe\u8868\u53ef\u4ee5\u9009\u7528\u8fed\u4ee3\u6216\u9012\u5f52\u65b9\u5f0f\u5b8c\u6210\u53cd\u8f6c\u3002\u4f60\u80fd\u5426\u7528\u4e24\u79cd\u65b9\u6cd5\u89e3\u51b3\u8fd9\u9053\u9898\uff1f<\/p>\n\n\n\n<p class=\"has-text-align-center\"><strong>\u521d\u59cb\u4ee3\u7801<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><mark style=\"background-color:rgba(0, 0, 0, 0);color:#00ff2f\" class=\"has-inline-color\">\/**\n * Definition for singly-linked list.\n * struct ListNode {\n *     int val;\n *     ListNode *next;\n *     ListNode() : val(0), next(nullptr) {}\n *     ListNode(int x) : val(x), next(nullptr) {}\n *     ListNode(int x, ListNode *next) : val(x), next(next) {}\n * };\n *\/<\/mark>\nclass Solution {\npublic:\n    ListNode* reverseList(ListNode* head) {\n \n    }\n};<\/code><\/pre>\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>\u53d7\u4e0d\u4e86\u4e86\uff0c\u4e00\u62f3\u628a\u94fe\u8868\u6253\u7206<\/em><\/cite><\/blockquote>\n\n\n\n<p>\u53c8\u5199\u4e86\u904d\u8fd9\u9898\u611f\u53d7\u4e86\u4e0b\u3002\u53d1\u73b0\u4e0d\u592a\u597d\u7406\u89e3\u7684\u5730\u65b9\u662f\u4e3a\u4ec0\u4e48\u8981\u65b0\u5efa\u4e00\u4e2atmp\u8282\u70b9\uff0c\u800c\u53ea\u6709\u8fd4\u56de\u7684\u65f6\u5019\u7528\u5230\u4e86tmp\u8282\u70b9\u3002<\/p>\n\n\n\n<p>\u6808\u9876tmp\u8282\u70b9\u4fdd\u5b58\u7684\u662f\u8282\u70b9\u7684\u5730\u5740\u3002\u56e0\u4e3a\u6bcf\u6b21\u9012\u5f52\u8fd4\u56de\u65f6\u90fd\u5bf9tmp\u7684\u4e0a\u4e00\u4e2a\u8282\u70b9\uff08\u5c06\u5176next\u6307\u9488\u7f6e\u7a7a\uff09\u548c\u4e0b\u4e00\u4e2a\u8282\u70b9\uff08\u5c06\u5176next\u6307\u9488\u6307\u5411tmp\u7684\u4e0a\u4e00\u4e2a\u8282\u70b9\uff09\u8fdb\u884c\u64cd\u4f5c\uff0c\u552f\u72ec\u4e0d\u9700\u8981\u66f4\u6539tmp\u8282\u70b9\u672c\u8eab\u3002\u4e3a\u4e86\u66f4\u6539next\u540e\u4e0d\u4e22\u5931\u8be5\u8282\u70b9\u7684\u5730\u5740\uff0c\u6240\u4ee5\u5c06\u5176\u4f5c\u4e3a\u8fd4\u56de\u503c\u3002<\/p>\n\n\n\n<p>\u5f53\u7136\u6b64\u65f6\u8fd8\u8fd4\u56dehead\u662f\u4e0d\u884c\u7684\u3002head\u5728\u6bcf\u6b21\u7684\u9012\u5f52\u5f39\u51fa\u6808\u7684\u90a3\u4e2a\u8fc7\u7a0b\u4e2d\uff0c\u6bcf\u6b21\u90fd\u88ab\u66f4\u6539\u4e3a\u4e86\u65b0\u7684\u5c3e\u8282\u70b9\u3002\u6240\u4ee5\u4f60\u8fd4\u56dehead\u7684\u8bdd\u6700\u540e\u8fd4\u56de\u7684\u662f\u53cd\u8f6c\u94fe\u8868\u7684\u5c3e\u8282\u70b9\u3002<\/p>\n\n\n\n<p class=\"has-text-align-center\"><strong>\u5b8c\u6574\u4ee3\u7801<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><mark style=\"background-color:rgba(0, 0, 0, 0);color:#00ff2f\" class=\"has-inline-color\">\/**\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 *\/<\/mark>\r\nclass Solution {\r\npublic:\r\n    ListNode* reverseList(ListNode* head) {\r\n        if(head==NULL||head->next==NULL)\r\n            return head;\r\n        ListNode*tmp=reverseList(head->next);\r\n        head->next->next=head;\r\n        head->next=NULL;\r\n        return tmp;\r\n    }\r\n};<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>LeetCode\u9898\u76ee\uff1a\u94fe\u8868\u7684\u9012\u5f52<\/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\/1247"}],"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=1247"}],"version-history":[{"count":0,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/posts\/1247\/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=1247"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/categories?post=1247"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/tags?post=1247"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}