/*
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 last=first;
while(pHead!=null&&pHead.next!=null){
if(pHead.val==pHead.next.val){
while(pHead.val==pHead.next.val){
pHead=pHead.next;
if(pHead.next==null) {
last.next=null;
return first.next;
}
}
last.next=pHead.next;
pHead=pHead.next;
}
else{
last=pHead;
pHead=pHead.next;
}
}
return first.next;
}
}