{"id":38356,"date":"2023-12-11T14:44:13","date_gmt":"2023-12-11T06:44:13","guid":{"rendered":"https:\/\/wx.kaifamiao.info\/?p=38356"},"modified":"2023-12-11T14:44:13","modified_gmt":"2023-12-11T06:44:13","slug":"%e6%89%8b%e5%86%99%e4%bb%a3%e7%a0%81%ef%bc%9a%e4%b8%80%e4%b8%aa%e5%8d%95%e5%90%91%e9%93%be%e8%a1%a8%ef%bc%8c%e7%bb%99%e5%87%ba%e5%a4%b4%e7%bb%93%e7%82%b9%ef%bc%8c%e6%89%be%e5%87%ba%e5%80%92%e6%95%b0","status":"publish","type":"post","link":"http:\/\/wx.kaifamiao.info\/index.php\/2023\/12\/11\/%e6%89%8b%e5%86%99%e4%bb%a3%e7%a0%81%ef%bc%9a%e4%b8%80%e4%b8%aa%e5%8d%95%e5%90%91%e9%93%be%e8%a1%a8%ef%bc%8c%e7%bb%99%e5%87%ba%e5%a4%b4%e7%bb%93%e7%82%b9%ef%bc%8c%e6%89%be%e5%87%ba%e5%80%92%e6%95%b0\/","title":{"rendered":"\u624b\u5199\u4ee3\u7801\uff1a\u4e00\u4e2a\u5355\u5411\u94fe\u8868\uff0c\u7ed9\u51fa\u5934\u7ed3\u70b9\uff0c\u627e\u51fa\u5012\u6570\u7b2cN\u4e2a\u7ed3\u70b9\uff0c\u8981\u6c42O\uff08N\uff09\u7684\u65f6\u95f4\u590d\u6742\u5ea6?"},"content":{"rendered":"<p>&#8220;`&#8221;                    \u53c2\u8003\u56de\u7b54\uff1a<\/p>\n<p>JAVA\u7248\u672c\uff1a<\/p>\n<p>&lt;pre&gt;&lt;code&gt;public class Solution {<br \/>\npublic ListNode FindNthToTail(ListNode head,int N) {<br \/>\nListNode pre=null,p=null;<br \/>\n\/\/\u4e24\u4e2a\u6307\u9488\u90fd\u6307\u5411\u5934\u7ed3\u70b9<br \/>\np=head;<br \/>\npre=head;<\/p>\n<p>\/\/\u8bb0\u5f55N\u503c<br \/>\nint a=N;<\/p>\n<p>\/\/\u8bb0\u5f55\u8282\u70b9\u7684\u4e2a\u6570<br \/>\nint count=0;<\/p>\n<p>\/\/p\u6307\u9488\u5148\u8dd1\uff0c\u5e76\u4e14\u8bb0\u5f55\u8282\u70b9\u6570\uff0c\u5f53p\u6307\u9488\u8dd1\u4e86N-1\u4e2a\u8282\u70b9\u540e\uff0cpre\u6307\u9488\u5f00\u59cb\u8dd1\uff0c<br \/>\n\/\/\u5f53p\u6307\u9488\u8dd1\u5230\u6700\u540e\u65f6\uff0cpre\u6240\u6307\u6307\u9488\u5c31\u662f\u5012\u6570\u7b2cN\u4e2a\u8282\u70b9<br \/>\nwhile(p!=null){<br \/>\np=p.next;<br \/>\ncount++;<br \/>\nif(N&lt;1){<br \/>\npre=pre.next;<br \/>\n}<br \/>\nN&#8211;;<br \/>\n}<\/p>\n<p>\/\/\u5982\u679c\u8282\u70b9\u4e2a\u6570\u5c0f\u4e8e\u6240\u6c42\u7684\u5012\u6570\u7b2cN\u4e2a\u8282\u70b9\uff0c\u5219\u8fd4\u56de\u7a7a<br \/>\nif(count&lt;a) return null;<br \/>\nreturn pre;<br \/>\n}<br \/>\n}<\/p>\n<p>&lt;\/code&gt;&lt;\/pre&gt;<\/p>\n<p>\u00a0<\/p>\n<p>C\/C++\u7248\u672c\uff1a<\/p>\n<p>&lt;pre&gt;&lt;code class=&quot;&quot;language-c++&quot;&quot; lang=&quot;&quot;c++&quot;&quot;&gt;class Solution {<br \/>\npublic:<br \/>\nListNode* FindNthToTail(ListNode* pListHead, unsigned int N) {<br \/>\nif(pListHead==NULL||N==0)<br \/>\nreturn NULL;<br \/>\nListNode*pTail=pListHead,*pHead=pListHead;<br \/>\nfor(int i=1;i&lt;N;++i)<br \/>\n{<br \/>\nif(pHead-&gt;next!=NULL)<br \/>\npHead=pHead-&gt;next;<br \/>\nelse<br \/>\nreturn NULL;<br \/>\n}<br \/>\nwhile(pHead-&gt;next!=NULL)<br \/>\n{<br \/>\npHead=pHead-&gt;next;<br \/>\npTail=pTail-&gt;next;<br \/>\n}<br \/>\nreturn pTail;<br \/>\n}<br \/>\n};<br \/>\nPython\uff1a<br \/>\nclass Solution:<br \/>\ndef FindNthToTail(self, head, N):<br \/>\n# write code here<br \/>\nres=[]<br \/>\nwhile head:<br \/>\nres.append(head)<br \/>\nhead=head.next<br \/>\nif N&gt;len(res) or N&lt;1:<br \/>\nreturn<br \/>\nreturn res[-N]<\/p>\n<p>&lt;\/code&gt;&lt;\/pre&gt;<\/p>\n<p>\u00a0<\/p>\n<p>&lt;pre&gt;&lt;code&gt;            &quot;&#8220;`<br \/>\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>&#8220;`&#8221; \u53c2\u8003\u56de\u7b54\uff1a JAVA\u7248\u672c\uff1a &lt;pre&gt;&lt;code&gt;pu [&hellip;]<\/p>\n","protected":false},"author":7,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[101],"tags":[],"class_list":["post-38356","post","type-post","status-publish","format-standard","hentry","category-c"],"_links":{"self":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts\/38356","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/comments?post=38356"}],"version-history":[{"count":1,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts\/38356\/revisions"}],"predecessor-version":[{"id":38357,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts\/38356\/revisions\/38357"}],"wp:attachment":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/media?parent=38356"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/categories?post=38356"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/tags?post=38356"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}