/* public class ListNode { int val; ListNode next = null; ListNode(int val) { this.val = val; } } */ public class Solution { public ListNode deleteDuplication(ListNode pHead) { ListNode first = new ListNode(-1); first.next = pHead; ListNode pre = first; ListNode cur = pHead; while(cur != null){ if (cur.next !=null && cur.val == cur.next.val){ while(cur.next !=null &&cur.val == cur.next.val){ cur = cur.next; } pre.next = cur.next; cur = cur.next; }else{ pre = cur; cur = cur.next; } } return first.next; } }