@@ -0,0 +1,1202 @@
+package leetcode.remove_duplicates_from_sorted_list_ii;%0A%0Aimport java.util.ArrayList;%0Aimport java.util.Random;%0A%0Aimport common.ListNode;%0A%0Apublic class Solution %7B%0A%09public ListNode deleteDuplicates(ListNode head) %7B%0A%09%09if(head == null) return null;%0A%09%09ListNode cur = head;%0A%09%09ListNode prev = null;%0A%09%09while(cur != null)%7B%0A%09%09%09boolean dup = false;%0A%09%09%09while(cur.next != null && cur.next.val == cur.val)%7B%0A%09%09%09%09cur.next = cur.next.next;%0A%09%09%09%09dup = true;%0A%09%09%09%7D%0A%09%09%09ListNode nxt = cur.next;%0A%09%09%09if(dup)%7B%0A%09%09%09%09if(prev == null)%7B%0A%09%09%09%09%09head = nxt;%0A%09%09%09%09%7Delse%7B%0A%09%09%09%09%09prev.next = nxt;%0A%09%09%09%09%7D%0A%09%09%09%7Delse%7B%0A%09%09%09%09prev = cur;%0A%09%09%09%7D%0A%09%09%09cur = nxt;%0A%09%09%7D%0A%09%09return head;%0A%09%7D%0A%0A%09public static void dump(ListNode head)%7B%0A%09%09ListNode cur = head;%0A%09%09while(cur != null)%7B%0A%09%09%09System.err.print(cur.val + %22, %22);%0A%09%09%09cur = cur.next;%0A%09%09%7D%0A%09%09System.err.println(%22%22);%0A%09%7D%0A%09%0A%09public static void main(String%5B%5D args)%7B%0A%09%09final int N = 3;%0A%09%09Random r = new Random();%0A%09%09ArrayList%3CListNode%3E ary = new ArrayList%3CListNode%3E();%0A%09%09for(int i = 0; i %3C N; i++)%7B%0A%09%09%09int v = 0;%0A%09%09%09if(i %3E 0) v = ary.get(i - 1).val; %0A%09%09%09ary.add(new ListNode(v + r.nextInt(2)));%0A%09%09%09if(i %3E 0) ary.get(i - 1).next = ary.get(i);%0A%09%09%7D%0A%09%09dump(ary.get(0));%0A%09%09dump(new Solution().deleteDuplicates(ary.get(0)));%0A%09%7D%0A%7D%0A

Add java solution for 82. Remove Duplicates from Sorted List II