Simple C++ code


  • 0

    """
    class Solution {
    public:
    ListNode* deleteDuplicates(ListNode* head) {
    if(head == NULL) return head;

        ListNode** p = &head;
        while((*p)->next != NULL){
            if((*p)->next->val == (*p)->val){
                (*p)->next = (*p)->next->next;
            }
            else{
                p = &(*p)->next;
            }
        }
        return head;
    }
    

    };
    """


Log in to reply
 

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