@@ -0,0 +1,1859 @@
+package me.wayne.leetcodetop100.listnode;%0A%0Aimport me.wayne.leetcodetop100.ListNode;%0A%0A/**%0A * %E7%BB%99%E4%BD%A0%E9%93%BE%E8%A1%A8%E7%9A%84%E5%A4%B4%E7%BB%93%E7%82%B9 head %EF%BC%8C%E8%AF%B7%E5%B0%86%E5%85%B6%E6%8C%89 %E5%8D%87%E5%BA%8F %E6%8E%92%E5%88%97%E5%B9%B6%E8%BF%94%E5%9B%9E %E6%8E%92%E5%BA%8F%E5%90%8E%E7%9A%84%E9%93%BE%E8%A1%A8 %E3%80%82%0A * %3Cp%3E%0A * https://leetcode-cn.com/problems/sort-list/%0A */%0Apublic class LC148_SortList %7B%0A%0A    public ListNode sortList(ListNode head) %7B%0A        if (head == null %7C%7C head.next == null) %7B%0A            return head;%0A        %7D%0A%0A        ListNode half = getHalf(head);%0A        ListNode anotherHalf = half.next;%0A        half.next = null;%0A%0A        ListNode left = sortList(head);%0A        ListNode right = sortList(anotherHalf);%0A%0A        return mergeList(left, right);%0A    %7D%0A%0A    private ListNode getHalf(ListNode head) %7B%0A        ListNode fast = head;%0A        ListNode slow = head;%0A        ListNode pre = new ListNode(-1);%0A        pre.next = slow;%0A        while (fast != null) %7B%0A            fast = fast.next;%0A            if (fast == null) %7B%0A                break;%0A            %7D%0A%0A            fast = fast.next;%0A            slow = slow.next;%0A            pre = pre.next;%0A        %7D%0A        return pre;%0A    %7D%0A%0A    private ListNode mergeList(ListNode head1, ListNode head2) %7B%0A        ListNode dummy = new ListNode(-1);%0A        ListNode head = dummy;%0A        while (head1 != null %7C%7C head2 != null) %7B%0A            if (head1 == null %7C%7C head2 == null) %7B%0A                if (head1 == null) %7B%0A                    dummy.next = head2;%0A                    head2 = head2.next;%0A                %7D else %7B%0A                    dummy.next = head1;%0A                    head1 = head1.next;%0A                %7D%0A            %7D else %7B%0A                if (head1.val %3C= head2.val) %7B%0A                    dummy.next = head1;%0A                    head1 = head1.next;%0A                %7D else %7B%0A                    dummy.next = head2;%0A                    head2 = head2.next;%0A                %7D%0A            %7D%0A            dummy = dummy.next;%0A        %7D%0A        return head.next;%0A    %7D%0A%7D%0A

add LC148_SortList