remove duplicates from a linked list without a data structure