Domanda di colloquio di Goldman Sachs

How do you reverse a linked list? Write the code.

Risposta di colloquio

Anonimo

31 lug 2009

void reverse(node** head) { node* cur = *head; *head = null; while (cur) { node* next = cur->next; cur->next = *head; *head = cur; cur = next; } }

4