Intel Corporation Interview Question

Given a connected list of elements (one directional), reverse it.

Interview Answers

Anonymous

Mar 8, 2013

stat at first element, hold it in a temp variable, go to its next, also keep the 3rd as a temp variable, and reverse the 2nd to point to the 1st etc.

Anonymous

Apr 6, 2015

Sounds like reversing a linked list to me: void reverseLinkList (Node *node) { if (node->next == null) return; reverseLinkList (node->next); node->next->next = node; }