{"id":45314,"date":"2023-12-11T15:05:29","date_gmt":"2023-12-11T07:05:29","guid":{"rendered":"https:\/\/wx.kaifamiao.info\/?p=45314"},"modified":"2023-12-11T15:05:29","modified_gmt":"2023-12-11T07:05:29","slug":"%e9%9a%8f%e6%9c%ba%e9%93%be%e8%a1%a8%e7%9a%84%e5%a4%8d%e5%88%b6-2","status":"publish","type":"post","link":"http:\/\/wx.kaifamiao.info\/index.php\/2023\/12\/11\/%e9%9a%8f%e6%9c%ba%e9%93%be%e8%a1%a8%e7%9a%84%e5%a4%8d%e5%88%b6-2\/","title":{"rendered":"\u968f\u673a\u94fe\u8868\u7684\u590d\u5236"},"content":{"rendered":"<p>&#8220;`&#8221;                    \u8003\u5bdf\u70b9\uff1a\u94fe\u8868<\/p>\n<p>\u00a0<\/p>\n<p>&lt;pre&gt;&lt;code class=&quot;&quot;language-java&quot;&quot; lang=&quot;&quot;java&quot;&quot;&gt;public RandomListNode copyRandomList(RandomListNode head) {<\/p>\n<p>    if (head == null)<br \/>\n        return null;<\/p>\n<p>    RandomListNode p = head;<\/p>\n<p>    \/\/ copy every node and insert to list<br \/>\n    while (p != null) {<br \/>\n        RandomListNode copy = new RandomListNode(p.label);<br \/>\n        copy.next = p.next;<br \/>\n        p.next = copy;<br \/>\n        p = copy.next;<br \/>\n    }<\/p>\n<p>    \/\/ copy random pointer for each new node<br \/>\n    p = head;<br \/>\n    while (p != null) {<br \/>\n        if (p.random != null)<br \/>\n            p.next.random = p.random.next;<br \/>\n        p = p.next.next;<br \/>\n    }<\/p>\n<p>    \/\/ break list to two<br \/>\n    p = head;<br \/>\n    RandomListNode newHead = head.next;<br \/>\n    while (p != null) {<br \/>\n        RandomListNode temp = p.next;<br \/>\n        p.next = temp.next;<br \/>\n        if (temp.next != null)<br \/>\n            temp.next = temp.next.next;<br \/>\n        p = p.next;<br \/>\n    }<\/p>\n<p>    return newHead;<br \/>\n}<br \/>\n&lt;\/code&gt;&lt;\/pre&gt;<\/p>\n<p>&lt;pre&gt;&lt;code&gt;            &quot;&#8220;`<br \/>\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>&#8220;`&#8221; \u8003\u5bdf\u70b9\uff1a\u94fe\u8868 \u00a0 &lt;pre&gt;&lt;code class=&#038;quo [&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-45314","post","type-post","status-publish","format-standard","hentry","category-c"],"_links":{"self":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts\/45314","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=45314"}],"version-history":[{"count":1,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts\/45314\/revisions"}],"predecessor-version":[{"id":45315,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts\/45314\/revisions\/45315"}],"wp:attachment":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/media?parent=45314"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/categories?post=45314"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/tags?post=45314"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}