思路

解答

class Solution {
    public ListNode deleteDuplicates(ListNode head) {
        if(head == null){
            return head;
        }

        ListNode cur = head;
        ListNode next = head.next;

        while(next != null){
            if(next.val == cur.val){
                next = next.next;
                cur.next = next;
            }else{
                 next = next.next;
                 cur = cur.next;
            }
        }
        return head;
    }
}

Vocabulary

字典連結

xxxx [KK] : (注意事項)