added solution for LinkedList