import java.util.*;
/*
* public class ListNode {
* int val;
* ListNode next = null;
* }
*/
public class Solution {
/**
*
* @param head ListNode类
* @return ListNode类
*/
public ListNode deleteDuplicates (ListNode head) {
// write code here
ListNode tmp=head;
if(head==null||head.next==null) return head;
while(head!=null&&head.next!=null&&head.val==head.next.val)
{
int i = 0;
while(head!=null&&head.next!=null&&head.val==head.next.val) {head = head.next;tmp=head.next;i=1;}
if(i==1) head = tmp;
}
if(tmp==null) return tmp;
tmp.next = deleteDuplicates(tmp.next);
return tmp;
}
}