LeetCode Remove Duplicated from Sorted List

    public ListNode deleteDuplicates(ListNode head) {
        if(head==null || head.next==null)
            return head;
        ListNode pre=head;;
        ListNode p=head.next;
        while(p!=null)
        {
            if(p.val==pre.val)
            {
                pre.next=p.next;
                p=p.next;
            }
            else
            {
                pre=p;
                p=p.next;
            }
        }
        return head;
    }
原文地址:https://www.cnblogs.com/maydow/p/4634172.html