Solution To Remove Duplicates in a Sorted linked List


#1

listnode* deleteDuplicates(listnode* A) {
listnode*head=A;
while(head!=NULL && head->next!=NULL)
{
if(head->val==head->next->val)
{
listnode * temp=head->next;
head->next=temp->next;
free(temp);
continue;
}
else
head=head->next;
}
return A;
}