You are viewing a single comment's thread. Return to all comments →
Only one line difference from the previous task (Scala):
def reverse(llist: DoublyLinkedListNode): DoublyLinkedListNode = { def reverseNode(node: DoublyLinkedListNode, next: DoublyLinkedListNode): DoublyLinkedListNode = if (node == null) next else { val prev = node.next node.prev = prev node.next = next reverseNode(prev, node) } reverseNode(llist, null) }
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 →
Only one line difference from the previous task (Scala):