completed hackerrank challenge 'print the elements of a linked list'