Question d’entretien chez Riot Games

Describe how you would reverse a linked list.

Réponse à la question d'entretien

Utilisateur anonyme

12 mai 2013

I did two approaches on my answer. The first was recursive (i.e. it takes longer and uses more space the more nodes there are) and the second was linear, which ran in constant time. The prototypes looked like this: A) Recursive: Node * ReverseList(Node * current, Node *prev) { } B) Linear Node * ReverseList(Node * oldTopOfList) { }