Custom Solution Problem 12 of LinkedList