Commonly asked Data Structures and Algorithms Problems by big tech and different solution approaches with code in Java and C

Powered by Blogger.

Tuesday, January 2, 2018

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;
    }

0 Comments:

Post a Comment

Stats