Hello regarding the following code I have the doubt, why am I returning the head? I understand the code, but my confusion comes from the fact that the head is never altered.
I feel as if I am given a linked list 1 -> 2 - > 2- > 2 and returning the same thing.
This code works
Node removeDuplicates(Node head)
{
Node current = head;
while(current.next!= null){
if(current.next.data == current.data)
current.next = current.next.next;
else
current = current.next;
}
return head;```
again, my confusion comes from the head not being altered. It feels so odd.
