{"id":2381,"date":"2023-10-12T09:44:51","date_gmt":"2023-10-12T01:44:51","guid":{"rendered":"https:\/\/white-night.club\/?p=2381"},"modified":"2023-11-09T11:07:50","modified_gmt":"2023-11-09T03:07:50","slug":"ad43","status":"publish","type":"post","link":"https:\/\/white-night.club\/index.php\/2023\/10\/12\/ad43\/","title":{"rendered":"\u9762\u8bd5\u9898 02.02.\u00a0\u8fd4\u56de\u5012\u6570\u7b2c k \u4e2a\u8282\u70b9"},"content":{"rendered":"\n<p>\u5b9e\u73b0\u4e00\u79cd\u7b97\u6cd5\uff0c\u627e\u51fa\u5355\u5411\u94fe\u8868\u4e2d\u5012\u6570\u7b2c k \u4e2a\u8282\u70b9\u3002\u8fd4\u56de\u8be5\u8282\u70b9\u7684\u503c\u3002<\/p>\n\n\n\n<p><strong>\u6ce8\u610f\uff1a<\/strong>\u672c\u9898\u76f8\u5bf9\u539f\u9898\u7a0d\u4f5c\u6539\u52a8<\/p>\n\n\n\n<p><strong>\u793a\u4f8b\uff1a<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><strong>\u8f93\u5165\uff1a<\/strong> 1-&gt;2-&gt;3-&gt;4-&gt;5 \u548c <em>k<\/em> = 2\n<strong>\u8f93\u51fa\uff1a <\/strong>4<\/pre>\n\n\n\n<p><strong>\u8bf4\u660e\uff1a<\/strong><\/p>\n\n\n\n<p>\u7ed9\u5b9a\u7684&nbsp;<em>k<\/em>&nbsp;\u4fdd\u8bc1\u662f\u6709\u6548\u7684\u3002<\/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\">\n<p>\u89e3\u9898\u601d\u8def<\/p>\n<cite><em>\u94fe\u8868\u53cc\u6307\u9488<\/em><\/cite><\/blockquote>\n\n\n\n<p>\u4e4b\u524d\u5199\u8fc7\u4e86\uff0c\u8fd9\u9053\u9898\u53ea\u662f\u628areturn\u7684\u7c7b\u578b\u6539\u6210\u4e86int\u800c\u5df2\u3002<\/p>\n\n\n\n<p>\u6709\u90a3\u4e48\u4e00\u77ac\u95f4\u6211\u60f3\u628aslow\u6307\u9488\u6307\u5411head\u7684\u524d\u4e00\u4e2a\u54d1\u5143\u8282\u70b9NULL\u3002\u4f46\u4ed4\u7ec6\u60f3\u4e0bslow\u6307\u9488\u4ece\u5934\u8282\u70b9\u51fa\u53d1\u8d70n-k\u6b65\uff0c\u8d70\u5230\u7684\u662f\u7b2cn-k+1\u4e2a\u4f4d\u7f6e\uff0c\u521a\u597d\u8d70\u5230\u5012\u6570\u7b2ck\u4e2a\u5143\u7d20\u7684\u6b63\u4e0a\u65b9\u3002\u4e0d\u5f97\u4e0d\u8bf4\u8fd9\u4e2a\u5730\u65b9\u7684\u8ff7\u60d1\u6027\u8fd8\u662f\u6bd4\u8f83\u5f3a\u7684\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(int x) : val(x), next(NULL) {}\r\n * };\r\n *\/\r\nclass Solution {\r\npublic:\r\n    int kthToLast(ListNode* head, int k) {\r\n        ListNode*fast=head,*slow=head;\r\n        while(k--)\r\n        {\r\n            fast=fast->next;\r\n        }\r\n        while(fast!=NULL)\r\n        {\r\n            slow=slow->next;\r\n            fast=fast->next;\r\n        }\r\n        return slow->val;\r\n    }\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\/2381"}],"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=2381"}],"version-history":[{"count":0,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/posts\/2381\/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=2381"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/categories?post=2381"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/tags?post=2381"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}