You are viewing a single comment's thread. Return to all comments →
if(head==null) return null;
while(head.next!=null&&head.data==head.next.data) {head.next=head.next.next;}
RemoveDuplicates(head.next);
return head;
Delete duplicate-value nodes from a sorted linked list
You are viewing a single comment's thread. Return to all comments →
a lil shorter version
if(head==null) return null;
while(head.next!=null&&head.data==head.next.data) {head.next=head.next.next;}
RemoveDuplicates(head.next);
return head;