1. 判断是否为null,直接返回
  2. 不能null,那么就遍历,获取下一节点,与当前节点比较,如果值相同,那么以下一节点为起始点,往下找不等于当前节点的值的指针
  3. 如果找到,当前节点下一节点指向找到的节点,当前节点指向找到的节点继续,直到为null

/*
 * public class ListNode {
 *   int val;
 *   ListNode next = null;
 * }
 */

public class Solution {
    /**
     * 
     * @param head ListNode类 
     * @return ListNode类
     */
    public ListNode deleteDuplicates (ListNode head) {
        
        if(head == null){
            return null;
        }
        ListNode cur = head;
        while(cur!=null){
            ListNode temp = cur.next;
            if(temp!=null && (temp.val == cur.val)){
                ListNode tt = temp;
                ListNode res = null;
                while(tt!=null){
                    if(tt.val!= temp.val){
                        res = tt;
                        break;
                    }
                    tt = tt.next;
                }
                cur.next = res;
                cur = cur.next;
            }else{
                cur = cur.next;
            }
        }
        return head;
    }
}