my c++ solution(easy to understand)


  • 0
    V
        ListNode* deleteDuplicates(ListNode* head) {    
            if(head==NULL) return NULL;
            ListNode* cur =head;     
            while(cur->next)
                if(cur->val==cur->next->val) cur->next=cur->next->next;
                else cur=cur->next;                 
            return head;   
        }
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.