import java.util.*;
public class Solution {public ListNode deleteDuplication(ListNode pHead) {ListNode res = new ListNode(-1);ListNode p=pHead;ListNode pre = res;while (p != null) {if (p.next == null || p.next.val != p.val) {pre.next = p;pre = p;}while (p.next != null && p.val == p.next.val) p = p.next;p = p.next;}pre.next = null;return res.next;}
}
class Solution {public ListNode deleteDuplication(ListNode head) {if (head == null) return head;ListNode dummy = new ListNode(-109);ListNode tail = dummy;while (head != null) {if (tail.val != head.val) {tail.next = head;tail = tail.next;}head = head.next;}tail.next = null;return dummy.next;}
}