You are viewing a single comment's thread. Return to all comments →
A straightforward C++ implementation:
SinglyLinkedListNode *prev, *follow; follow = llist->next; int count = 1; while (follow != NULL) { prev = llist; llist = follow; follow = llist->next; llist->next = prev; if (count == 1) { prev->next = NULL; count++; } } return llist;
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 →
A straightforward C++ implementation: