You are viewing a single comment's thread. Return to all comments →
Looks like there's an issue with the Java version. I submitted this,
Node newNode = new Node(); newNode.data = data; if(head == null || head.data >= data){ newNode.next = head; newNode.prev = null; return newNode; } Node current = head; Node prev = null; while(current != null && current.data < data){ prev = current; current = current.next; } Node next = prev.next; newNode.prev = prev; newNode.next = next; if(next != null){ next.prev = newNode; } return head;
and I see that the condition head == null is never satisfied. Can someone help?
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 →
Looks like there's an issue with the Java version. I submitted this,
and I see that the condition head == null is never satisfied. Can someone help?