You are viewing a single comment's thread. Return to all comments →
Recursion usually provides an elegant solution to these types of problems but in this case, it did not appear to have anything over simple iteration:
Node* Reverse(Node *head) { Node *tail, *t; tail = NULL; while (head != NULL) { t = head->next; head->next = tail; tail = head; head = t; } return tail; // Complete this method }
Seems like cookies are disabled on this browser, please enable them to open this website
Reverse a linked list
You are viewing a single comment's thread. Return to all comments →
Recursion usually provides an elegant solution to these types of problems but in this case, it did not appear to have anything over simple iteration: