{"id":45312,"date":"2023-12-11T15:05:28","date_gmt":"2023-12-11T07:05:28","guid":{"rendered":"https:\/\/wx.kaifamiao.info\/?p=45312"},"modified":"2023-12-11T15:05:28","modified_gmt":"2023-12-11T07:05:28","slug":"%e6%9c%89%e4%b8%80%e4%b8%aa%e9%93%be%e8%a1%a8%ef%bc%8c%e5%a5%87%e6%95%b0%e4%bd%8d%e5%8d%87%e5%ba%8f%e5%81%b6%e6%95%b0%e4%bd%8d%e9%99%8d%e5%ba%8f%ef%bc%8c%e5%a6%82%e4%bd%95%e5%b0%86%e9%93%be%e8%a1%a8-2","status":"publish","type":"post","link":"http:\/\/wx.kaifamiao.info\/index.php\/2023\/12\/11\/%e6%9c%89%e4%b8%80%e4%b8%aa%e9%93%be%e8%a1%a8%ef%bc%8c%e5%a5%87%e6%95%b0%e4%bd%8d%e5%8d%87%e5%ba%8f%e5%81%b6%e6%95%b0%e4%bd%8d%e9%99%8d%e5%ba%8f%ef%bc%8c%e5%a6%82%e4%bd%95%e5%b0%86%e9%93%be%e8%a1%a8-2\/","title":{"rendered":"\u6709\u4e00\u4e2a\u94fe\u8868\uff0c\u5947\u6570\u4f4d\u5347\u5e8f\u5076\u6570\u4f4d\u964d\u5e8f\uff0c\u5982\u4f55\u5c06\u94fe\u8868\u53d8\u6210\u5347\u5e8f"},"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 class OddIncreaseEvenDecrease {<br \/>\n    \/**<br \/>\n     * \u6309\u7167\u5947\u5076\u4f4d\u62c6\u5206\u6210\u4e24\u4e2a\u94fe\u8868<br \/>\n     * @param head<br \/>\n     * @return<br \/>\n     *\/<br \/>\n    public static Node[] getLists(Node head){<br \/>\n        Node head1 = null;<br \/>\n        Node head2 = null;<\/p>\n<p>        Node cur1 = null;<br \/>\n        Node cur2 = null;<br \/>\n        int count = 1;\/\/\u7528\u6765\u8ba1\u6570<br \/>\n        while(head != null){<br \/>\n            if(count % 2 == 1){<br \/>\n                if(cur1 != null){<br \/>\n                    cur1.next = head;<br \/>\n                    cur1 = cur1.next;<br \/>\n                }else{<br \/>\n                    cur1 = head;<br \/>\n                    head1 = cur1;<br \/>\n                }<br \/>\n            }else{<br \/>\n                if(cur2 != null){<br \/>\n                    cur2.next = head;<br \/>\n                    cur2 = cur2.next;<br \/>\n                }else{<br \/>\n                    cur2 = head;<br \/>\n                    head2 = cur2;<br \/>\n                }<br \/>\n            }<br \/>\n            head = head.next;<br \/>\n            count++;<br \/>\n        }<br \/>\n        \/\/\u8df3\u51fa\u5faa\u73af\uff0c\u8981\u8ba9\u6700\u540e\u4e24\u4e2a\u672b\u5c3e\u5143\u7d20\u7684\u4e0b\u4e00\u4e2a\u90fd\u6307\u5411null<br \/>\n        cur1.next = null;<br \/>\n        cur2.next = null;<\/p>\n<p>        Node[] nodes = new Node[]{head1,head2};<br \/>\n        return nodes;<br \/>\n    }<\/p>\n<p>    \/**<br \/>\n     * \u53cd\u8f6c\u94fe\u8868<br \/>\n     * @param head<br \/>\n     * @return<br \/>\n     *\/<br \/>\n    public static Node reverseList(Node head){<br \/>\n        Node pre = null;<br \/>\n        Node next = null;<br \/>\n        while(head != null){<br \/>\n            next = head.next;<br \/>\n            head.next = pre;<br \/>\n            pre = head;<br \/>\n            head = next;<br \/>\n        }<br \/>\n        return pre;<br \/>\n    }<\/p>\n<p>    \/**<br \/>\n     * \u5408\u5e76\u4e24\u4e2a\u6709\u5e8f\u94fe\u8868<br \/>\n     * @param head1<br \/>\n     * @param head2<br \/>\n     * @return<br \/>\n     *\/<br \/>\n    public static Node CombineList(Node head1,Node head2){<br \/>\n        if(head1 == null || head2 == null){<br \/>\n            return head1 != null ? head1 :head2;<br \/>\n        }<br \/>\n        Node head = head1.value &lt; head2.value ?head1 : head2;<br \/>\n        Node cur1 = head == head1 ? head1 :head2;<br \/>\n        Node cur2 = head == head1 ? head2 :head1;<br \/>\n        Node pre = null;<br \/>\n        Node next = null;<br \/>\n        while(cur1 != null &amp;&amp; cur2 !=null){<br \/>\n            if(cur1.value &lt;= cur2.value){\/\/\u8fd9\u91cc\u4e00\u5b9a\u8981\u6709=\uff0c\u5426\u5219\u4e00\u65e6cur1\u7684value\u548ccur2\u7684value\u76f8\u7b49\u7684\u8bdd\uff0c\u4e0b\u9762\u7684pre.next\u4f1a\u51fa\u73b0\u7a7a\u6307\u9488\u5f02\u5e38<br \/>\n                pre = cur1;<br \/>\n                cur1 = cur1.next;<br \/>\n            }else{<br \/>\n                next = cur2.next;<br \/>\n                pre.next = cur2;<br \/>\n                cur2.next = cur1;<br \/>\n                pre = cur2;<br \/>\n                cur2 = next;<br \/>\n            }<br \/>\n        }<br \/>\n        pre.next = cur1 == null ? cur2 : cur1;<\/p>\n<p>        return head;<br \/>\n    }<\/p>\n<p>}<br \/>\n&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; \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-45312","post","type-post","status-publish","format-standard","hentry","category-c"],"_links":{"self":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts\/45312","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=45312"}],"version-history":[{"count":1,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts\/45312\/revisions"}],"predecessor-version":[{"id":45313,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts\/45312\/revisions\/45313"}],"wp:attachment":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/media?parent=45312"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/categories?post=45312"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/tags?post=45312"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}