You are viewing a single comment's thread. Return to all comments →
Java
public static DoublyLinkedListNode reverse(DoublyLinkedListNode llist) { DoublyLinkedListNode prevNode = null; DoublyLinkedListNode currentNode = llist; DoublyLinkedListNode nextNode = null; while (currentNode != null) { // swap pointers nextNode = currentNode.next; currentNode.next = prevNode; currentNode.prev = nextNode; // save previous prevNode = currentNode; // move along currentNode = nextNode; } return prevNode; }
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 →
Java