Pregunta de entrevista de JetBrains

You have a single-linked list. Write code to reverse it.