Exemplo n.º 1
0
void RemoveDuplicate2(Node* head)
{
    Node* p = head->next;

    if(p == NULL)
        return;

    HashTable tbl;

    while(p->next!=NULL)
    {
        Node* t = NULL;

        if(tbl.Contains(p->next->val))
        {
            p->next = p->next->next;
        }
        else
        {
            tbl.AddEntry(p->next->val);
            p = p->next;
        }
    }


}
Exemplo n.º 2
0
void RemoveDuplicate(Node* head)
{
    HashTable tbl;
    Node* prev = head;
    Node* curr = head;
    while(curr!=NULL)
    {
        Node* t = NULL;
        if(tbl.Contains(curr->val))
        {
            prev->next = curr->next;
            t = curr;
        }
        else
        {
            tbl.AddEntry(curr->val);
            prev = curr;
        }
        curr = curr->next;
    }
}