Bloomberg Interview Question

They asked me to reverse a linked list.

Interview Answer

Anonymous

Dec 28, 2015

Node *cur = head, *pre = NULL; while(cur != NULL){ Node *next = cur->next; cur->next = pre; pre = cur; cur = next; } head = pre;