Wednesday 8 November 2017

Delete duplicate-value nodes from a sorted linked list Hacker rank solution in C

Node* RemoveDuplicates(Node *head)
{
    Node *c=head;
    if(head == NULL || head ->next == NULL)
        return head;
    while(c->next != NULL)
    {
        if(c->data == c->next->data)
        {
            c->next = c->next->next;
        }
        else
            c=c->next;           
    }
    return head;
}

No comments:

Post a Comment