Delete duplicate-value nodes from a sorted linked list

  • + 0 comments
        SinglyLinkedListNode* temp1;
        temp1=llist;
        
        while(temp1!=nullptr&&temp1->next!=nullptr)
        {
            if(temp1->data==temp1->next->data)
            {
                temp1->next=temp1->next->next;
            }else
            {
                temp1=temp1->next;
            }
                
        }
        
        return llist;
    }