You are viewing a single comment's thread. Return to all comments →
My answer in Python:
def sortedInsert(llist, data): node = llist dummy = DoublyLinkedListNode(0) dummy.next = node prev = dummy data = DoublyLinkedListNode(data) while node: if node.data >= data.data: break prev = node node = node.next prev.next = data data.prev = prev data.next = node if node: node.prev = data return dummy.next
Seems like cookies are disabled on this browser, please enable them to open this website
An unexpected error occurred. Please try reloading the page. If problem persists, please contact support@hackerrank.com
Inserting a Node Into a Sorted Doubly Linked List
You are viewing a single comment's thread. Return to all comments →
My answer in Python: