Linklist/Remove Duplicated of a LinkList.cpp
// Function to remove duplicated node !
Function to remove duplicated node !
Function to remove duplicated node !
void remove_duplicated()
{
    struct Node *node1, *node2, *temp;
    node1 = head;
    while(node1!=NULL && node1->next!=NULL)
    {
        node2 = node1;
        while(node2->next != NULL)
        {
            if(node1->data == node2->next->data)
            {
                temp = node2->next;
                node2->next = node2->next->next;
                delete(temp);
            }
            else{
                node2 = node2->next;
            }
        }
        node1 = node1->next;
    }
}
void remove_duplicated ( ) { struct Node * node1 , * node2 , * temp ; node1 = head ; while ( node1 != NULL && node1 -> next != NULL ) { node2 = node1 ; while ( node2 -> next != NULL ) { if ( node1 -> data == node2 -> next -> data ) { temp = node2 -> next ; node2 -> next = node2 -> next -> next ; delete ( temp ) ; } else { node2 = node2 -> next ; } } node1 = node1 -> next ; } }
Function to remove duplicated node !
Function to remove duplicated node !
// If duplicate then delete it