/* public class ListNode { int val; ListNode next = null; ListNode(int val) { this.val = val; } } */ public class Solution { public ListNode deleteDuplication(ListNode pHead) { if(pHead == null || pHead.next == null){ return pHead; } ListNode node = new ListNode(0); node.next = pHead; ListNode preNode = node; ListNode cur = pHead; while(cur != null){ while(cur != null && cur.next != null && cur.val == cur.next.val){ cur = cur.next; } if(preNode.next != cur){ preNode.next = cur.next; cur = cur.next; }else{ preNode = cur; cur = cur.next; } } return node.next; } }