递归应用-链表快速排序

在 O(n log n) 时间复杂度和常数级空间复杂度下,对链表进行排序。

leetcode

   public ListNode quickSortList(ListNode head) {
        if (head == null) return null;

        ListNode pivot = head;
        ListNode left = null, right = null;
        ListNode cur = head.next;
        while(cur != null) {
            ListNode n = cur.next;
            if (cur.val

你可能感兴趣的:(Java,Algorithm)