Polish linked list exercise