You are viewing a single comment's thread. Return to all comments →
Solution in Java 15:
public static DoublyLinkedListNode reverse(DoublyLinkedListNode llist) { // Write your code here DoublyLinkedListNode head = llist.next; DoublyLinkedListNode tail = llist; tail.next = null; tail.prev = head; while (head != null) { DoublyLinkedListNode nextPointer = head.next; head.next = tail; head.prev = nextPointer; tail = head; head = nextPointer; } return tail; }
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 Java 15: