@@ -0,0 +1,1638 @@
+/**%0A *%09Given a sorted linked list, delete all nodes that have duplicate numbers, %0A *%09leaving only distinct numbers from the original list.%0A *%0A *%09For example,%0A *%09Given 1-%3E2-%3E3-%3E3-%3E4-%3E4-%3E5, return 1-%3E2-%3E5.%0A *%09Given 1-%3E1-%3E1-%3E2-%3E3, return 2-%3E3.%0A *%0A *%09Author: matao%0A *%0A */%0A%0Aclass ListNode %7B%0A%09int val;%0A%09ListNode next;%0A%09ListNode(int x) %7B val = x; %7D%0A%7D%0A%0Apublic class RemoveDuplicatesfromSortedListII %7B%0A%09public static ListNode deleteDuplicates(ListNode head) %7B%0A        if(head == null %7C%7C head.next == null) %7B%0A        %09return head;%0A        %7D%0A%0A        ListNode dummy = new ListNode(0);%0A        dummy.next = head;%0A        head = dummy;%0A        while(head.next != null && head.next.next != null) %7B%0A        %09if (head.next.val == head.next.next.val) %7B%0A        %09%09int val = head.next.val;%0A        %09%09while(head.next != null && head.next.val == val) %7B%0A        %09%09%09head.next = head.next.next;%0A        %09%09%7D%0A        %09%7D else %7B%0A        %09%09head = head.next;%0A        %09%7D%0A        %7D%0A        return dummy.next;%0A    %7D%0A%0A    public static void main(String%5B%5D args) %7B%0A    %09ListNode node1 = new ListNode(1);%0A    %09ListNode node2 = new ListNode(2);%0A    %09ListNode node3 = new ListNode(3);%0A    %09ListNode node3_ = new ListNode(3);%0A    %09ListNode node4 = new ListNode(4);%0A    %09ListNode node4_ = new ListNode(4);%0A    %09ListNode node5 = new ListNode(5);%0A%0A    %09node1.next = node2;%0A    %09node2.next = node3;%0A    %09node3.next = node3_;%0A    %09node3_.next = node4;%0A    %09node4.next = node4_;%0A    %09node4_.next = node5;%0A%0A    %09ListNode node = deleteDuplicates(node1);%0A    %09while(node != null) %7B%0A    %09%09System.out.print(node.val + %22 %22);%0A    %09%09node = node.next;%0A    %09%7D%0A    %09System.out.println();%0A    %7D%0A%7D

add Remove Duplicates From SortedList II solution