C++,9ms


  • 0
    F

    '''
    class Solution {
    public:
    ListNode* deleteDuplicates(ListNode* head) {
    if(head == NULL)
    {
    return NULL;
    }
    ListNode* phead = head;
    ListNode* next = phead->next;
    ListNode* dup = NULL;
    while(next != NULL)
    {
    if( next->val == phead->val)
    {
    dup = next;
    next= next->next;
    phead->next = next;
    delete dup;
    dup = NULL;
    }
    else
    {
    phead = phead->next;
    next = next->next;
    }
    }
    return head;
    }
    '''
    };


Log in to reply
 

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