{"id":5138,"date":"2023-11-16T09:18:41","date_gmt":"2023-11-16T01:18:41","guid":{"rendered":"https:\/\/white-night.club\/?p=5138"},"modified":"2023-11-16T09:37:58","modified_gmt":"2023-11-16T01:37:58","slug":"ad151","status":"publish","type":"post","link":"https:\/\/white-night.club\/index.php\/2023\/11\/16\/ad151\/","title":{"rendered":"206.\u00a0\u53cd\u8f6c\u94fe\u8868\uff08GO\uff09"},"content":{"rendered":"\n<p>\u7ed9\u4f60\u5355\u94fe\u8868\u7684\u5934\u8282\u70b9\u00a0<code>head<\/code>\u00a0\uff0c\u8bf7\u4f60\u53cd\u8f6c\u94fe\u8868\uff0c\u5e76\u8fd4\u56de\u53cd\u8f6c\u540e\u7684\u94fe\u8868\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\"><strong>\u8f93\u5165\uff1a<\/strong>head = [1,2,3,4,5] <strong>\u8f93\u51fa\uff1a<\/strong>[5,4,3,2,1]<\/p>\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\"><strong>\u8f93\u5165\uff1a<\/strong>head = [1,2] <strong>\u8f93\u51fa\uff1a<\/strong>[2,1]<\/p>\n\n\n\n<p><strong>\u793a\u4f8b 3\uff1a<\/strong><strong>\u8f93\u5165\uff1a<\/strong>head = [] <strong>\u8f93\u51fa\uff1a<\/strong>[]<\/p>\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<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 has-link-color wp-elements-1cec460e85e101501641a003381f8f9c\">\n<p>\u89e3\u9898\u601d\u8def<\/p>\n<cite><em>GO\u94fe\u8868<\/em><\/cite><\/blockquote>\n\n\n\n<p>\u5148\u662f\u9012\u5f52\uff0c\u9012\u5f52\u6bd4\u8f83\u597d\u5199\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/**\r\n * Definition for singly-linked list.\r\n * type ListNode struct {\r\n *     Val int\r\n *     Next *ListNode\r\n * }\r\n *\/\r\nfunc reverseList(head *ListNode) *ListNode {\r\n    if head==nil||head.Next==nil{\r\n        return head\r\n    }\r\n    newHead:=reverseList(head.Next)\r\n    head.Next.Next=head\r\n    head.Next=nil\r\n    return newHead\r\n}<\/code><\/pre>\n\n\n\n<p>\u7136\u540e\u662f\u8fed\u4ee3\u3002\u8fed\u4ee3\u5199\u7684\u4e0d\u591f\u591a\u53cd\u800c\u6ca1\u6709\u9012\u5f52\u719f\u3002\u591a\u7ec3\u5427\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/**\r\n * Definition for singly-linked list.\r\n * type ListNode struct {\r\n *     Val int\r\n *     Next *ListNode\r\n * }\r\n *\/\r\nfunc reverseList(head *ListNode) *ListNode {\r\n    if head==nil||head.Next==nil{\r\n        return head\r\n    }\r\n    cur:=head\r\n    var newHead *ListNode\r\n    for cur!=nil{\r\n        tmp:=cur.Next\r\n        \/\/nil-1-2-3-nil\r\n        cur.Next=newHead\r\n        newHead=cur\r\n        cur=tmp\r\n    }\r\n    return newHead\r\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Leetcode\u9898\u76ee\uff1aGO\u94fe\u8868<\/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\/5138"}],"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=5138"}],"version-history":[{"count":0,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/posts\/5138\/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=5138"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/categories?post=5138"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/tags?post=5138"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}