Question d’entretien chez High Voltage

How do you reverse a linked list?

Réponses aux questions d'entretien

Utilisateur anonyme

25 janv. 2017

By pushing elements on a stack.

Utilisateur anonyme

8 juin 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.