solution for linkedlist problems