We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
defsortedInsert(llist,data):# Write your code herehead=llistifdata<head.data:dat=DoublyLinkedListNode(data)head.prev=datdat.next=headreturndatwhile(head):nex=head.nextifnotnex:dat=DoublyLinkedListNode(data)head.next=datbreakifnexanddata<nex.data:dat=DoublyLinkedListNode(data)head.next=datnex.prev=datdat.prev=headdat.next=nexbreakhead=head.nextreturnllist
this worked for me
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Inserting a Node Into a Sorted Doubly Linked List
You are viewing a single comment's thread. Return to all comments →
this worked for me