{"id":5480,"date":"2023-11-22T19:36:25","date_gmt":"2023-11-22T11:36:25","guid":{"rendered":"https:\/\/white-night.club\/?p=5480"},"modified":"2023-11-22T19:40:56","modified_gmt":"2023-11-22T11:40:56","slug":"ad161","status":"publish","type":"post","link":"https:\/\/white-night.club\/index.php\/2023\/11\/22\/ad161\/","title":{"rendered":"19.\u00a0\u5220\u9664\u94fe\u8868\u7684\u5012\u6570\u7b2c N \u4e2a\u7ed3\u70b9"},"content":{"rendered":"\n<p>\u7ed9\u4f60\u4e00\u4e2a\u94fe\u8868\uff0c\u5220\u9664\u94fe\u8868\u7684\u5012\u6570\u7b2c\u00a0<code>n<\/code><em>\u00a0<\/em>\u4e2a\u7ed3\u70b9\uff0c\u5e76\u4e14\u8fd4\u56de\u94fe\u8868\u7684\u5934\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\/2020\/10\/03\/remove_ex1.jpg\"><strong>\u8f93\u5165\uff1a<\/strong>head = [1,2,3,4,5], n = 2 <strong>\u8f93\u51fa\uff1a<\/strong>[1,2,3,5]<\/p>\n\n\n\n<p><strong>\u793a\u4f8b 2\uff1a<\/strong><strong>\u8f93\u5165\uff1a<\/strong>head = [1], n = 1 <strong>\u8f93\u51fa\uff1a<\/strong>[]<\/p>\n\n\n\n<p><strong>\u793a\u4f8b 3\uff1a<\/strong><strong>\u8f93\u5165\uff1a<\/strong>head = [1,2], n = 1 <strong>\u8f93\u51fa\uff1a<\/strong>[1]<\/p>\n\n\n\n<p><strong>\u63d0\u793a\uff1a<\/strong><\/p>\n\n\n\n<ul>\n<li>\u94fe\u8868\u4e2d\u7ed3\u70b9\u7684\u6570\u76ee\u4e3a&nbsp;<code>sz<\/code><\/li>\n\n\n\n<li><code>1 &lt;= sz &lt;= 30<\/code><\/li>\n\n\n\n<li><code>0 &lt;= Node.val &lt;= 100<\/code><\/li>\n\n\n\n<li><code>1 &lt;= n &lt;= sz<\/code><\/li>\n<\/ul>\n\n\n\n<p><strong>\u8fdb\u9636\uff1a<\/strong>\u4f60\u80fd\u5c1d\u8bd5\u4f7f\u7528\u4e00\u8d9f\u626b\u63cf\u5b9e\u73b0\u5417\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-db7d1dcdabd125fe3cb1cd106e289972\">\n<p>\u89e3\u9898\u601d\u8def<\/p>\n<cite><em>\u53cc\u6307\u9488<\/em><\/cite><\/blockquote>\n\n\n\n<p>\u7ecf\u5178\u5feb\u6162\u6307\u9488\u9898\u3002\u5feb\u6307\u9488\u5148\u8d70n\u6b65\uff0c\u5269\u4e0blen-n\u6b65\u6ca1\u8d70\u3002\u90a3\u6162\u6307\u9488\u518d\u4ecedummy\u8282\u70b9\u5f00\u59cb\u8d70len-n\u6b65\uff0c\u521a\u597d\u5c31\u5728\u8981\u5220\u9664\u8282\u70b9\u7684\u524d\u4e00\u4e2a\u4f4d\u7f6e\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 removeNthFromEnd(head *ListNode, n int) *ListNode {\r\n    dummy:=&amp;ListNode{0,head}\r\n    first:=head\r\n    second:=dummy\r\n    for i:=0;i&lt;n;i++{\r\n        first=first.Next\r\n    }\r\n    for first!=nil{\r\n        first=first.Next\r\n        second=second.Next\r\n    }\r\n    second.Next=second.Next.Next\r\n    return dummy.Next\r\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Leetcode\u9898\u76ee\uff1a\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\/5480"}],"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=5480"}],"version-history":[{"count":0,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/posts\/5480\/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=5480"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/categories?post=5480"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/tags?post=5480"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}