Does the code below look correct and efficient for removing duplicates from an unsorted linked list without using extra memory?
An object of type Node denotes a LL node.
void removeDuplicates()
{
Node current = head;
while(current!=null)
{
Node prev = current;
Node next = current.next;
while(next!=null)
{
if(current.equals(next))
{
prev.next = next.next;
}
else
{
prev = next;
}
next = next.next;
}
current = current.next;
}
}