Remove Duplicate in Sorted LinkedList
Code:
Node removeDuplicates(Node head)
{
Node res=head;
while(head.next!=null)
{
if(head.data==head.next.data)
head.next=head.next.next;
else
head=head.next;
}
return res;
}
Node removeDuplicates(Node head)
{
Node res=head;
while(head.next!=null)
{
if(head.data==head.next.data)
head.next=head.next.next;
else
head=head.next;
}
return res;
}
0 Comments:
Post a Comment