@@ -0,0 +1,1711 @@
+/**%0A * Partition List%0A * Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x.%0A * You should preserve the original relative order of the nodes in each of the two partitions.%0A * For example,%0A * Given 1-%3E4-%3E3-%3E2-%3E5-%3E2 and x = 3,%0A * return 1-%3E2-%3E2-%3E4-%3E3-%3E5.%0A * %0A * Node: create 2 ListNode one for node which is less than target , one for greater.%0A * Time Complexity O(n)%0A * @author chenshuna%0A *%0A */%0Apublic class PartitionList %7B%0A    public static ListNode partition(ListNode head, int x) %7B%0A        ListNode small = new ListNode(0);%0A        ListNode big = new ListNode(0);%0A        ListNode b = big;%0A        ListNode res = small;%0A        if(head == null %7C%7C head.next == null)%7B%0A            return head;%0A        %7D%0A        ListNode temp = head;%0A        while(temp != null)%7B%0A            if(temp.val %3C x)%7B%0A              small.next = temp;%0A              small = small.next;%0A              temp = temp.next;%0A            %7Delse%7B%0A             big.next = temp;%0A             big = big.next;%0A             temp = temp.next;%0A            %7D%0A        %7D%0A        big.next = null;%0A        if(b.next != null)%7B%0A            small.next = b.next;%0A        %7D%0A        return res.next;%0A    %7D%0A    public static void main(String%5B%5D args) %7B%0A        // TODO Auto-generated method stub%0A        ListNode res = new ListNode(1);%0A        res.next = new ListNode(2);%0A        res.next.next = new ListNode(4);%0A        res.next.next.next = new ListNode(5);%0A        res.next.next.next.next = new ListNode(3);%0A        res.next.next.next.next.next = new ListNode(7);%0A        while(res != null)%7B%0A            System.out.print(partition(res, 4).val);%0A            res = res.next;%0A        %7D%0A    %7D%0A%7D%0A

add 86