Pregunta de entrevista de Rattle

Solve data structure question. Had to use linked list