Pregunta de entrevista de High Voltage

How do you reverse a linked list?

Respuestas de entrevistas

Anónimo

25 ene 2017

By pushing elements on a stack.

Anónimo

8 jun 2020

Do it in place with 3 pointers. Previous, current, and next. Move the pointer on current from next to previous, then advance all 3 pointers. When next is null, current becomes your new head node. This avoids expensive memory allocations and minimizes writes to RAM.