You are viewing a single comment's thread. Return to all comments →
swift solution
func reverse(llist: DoublyLinkedListNode?) -> DoublyLinkedListNode? { // Write your code here var currentNode:DoublyLinkedListNode? = llist var reversed: DoublyLinkedListNode? //move tail while currentNode?.next != nil { currentNode = currentNode?.next } reversed = currentNode while currentNode != nil { currentNode?.next = currentNode?.prev currentNode?.prev = currentNode?.next currentNode = currentNode?.next } return reversed }
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 →
swift solution