You are viewing a single comment's thread. Return to all comments →
Solution in C++:
DoublyLinkedListNode* reverse(DoublyLinkedListNode* llist) { if (llist == nullptr) { return llist; } std::swap(llist->next, llist->prev); while (llist->prev != nullptr) { llist = llist->prev; std::swap(llist->next, llist->prev); } return llist; }
Seems like cookies are disabled on this browser, please enable them to open this website
Reverse a doubly linked list
You are viewing a single comment's thread. Return to all comments →
Solution in C++: