Skip to content

Latest commit

 

History

History
29 lines (22 loc) · 674 Bytes

Remove Duplicate in DLL.md

File metadata and controls

29 lines (22 loc) · 674 Bytes
Node * removeDuplicates(struct Node *head)
    {
        struct Node* p = head;
        
        while(p->next!=NULL)
        {
            if(p->data == p->next->data)
            {
                struct Node* nn = p->next->next;
                
                if(nn!=NULL)
                {
                    nn->prev =p;
                }
                p->next=nn;
            }
            
            else
            
                p=p->next;
        }
        
        return head;
    }