import java.util.*;
/*
* public class ListNode {
* int val;
* ListNode next = null;
* }
*/
public class Solution {
/**
*
* @param head ListNode类
* @return ListNode类
*/
// 重复的全给删了,一个不留!
public ListNode deleteDuplicates (ListNode head) {
if(head == null || head.next == null) return head;
ListNode fake_head = new ListNode(-1);
fake_head.next = head;
ListNode pre = fake_head,cur = head,next = head.next;
while(next != null){
if(cur.val == next.val){
while(cur != null && next != null && cur.val == next.val){
cur = next;
next = next.next;
} // 跳过重复元素!
pre.next = next;
}else {
pre = pre.next;
}
if(next != null) {
cur = next;
next = next.next;
}
}
return fake_head.next;
}
}