You are viewing a single comment's thread. Return to all comments →
SinglyLinkedListNode* reverse(SinglyLinkedListNode* llist) { SinglyLinkedListNode* prev = NULL; SinglyLinkedListNode* current = llist; SinglyLinkedListNode* next = NULL;
while (current != NULL) { next = current->next; current->next = prev; prev = current; current = next; } return prev;
}
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 →
SinglyLinkedListNode* reverse(SinglyLinkedListNode* llist) { SinglyLinkedListNode* prev = NULL; SinglyLinkedListNode* current = llist; SinglyLinkedListNode* next = NULL;
}