You are viewing a single comment's thread. Return to all comments →
Node mergeLists(Node headA, Node headB) { Node head= new Node(); Node headTemp= head; while(headA !=null || headB !=null) { if(headA.data<=headB.data && headA !=null && headB !=null) { head.next=headA; headA=headA.next; } else if(headA.data>=headB.data &&headA !=null && headB !=null){ head.next=headB; headB=headB.next; } else if(headA ==null){ head.next=headB; headB=headB.next; } else if(headB ==null){ head.next=headA; headA=headA.next; } head=head.next; } return headTemp.next; }
Why this is not working , can anybody give me the explaination please
Seems like cookies are disabled on this browser, please enable them to open this website
I agree to HackerRank's Terms of Service and Privacy Policy.
Merge two sorted linked lists
You are viewing a single comment's thread. Return to all comments →
Why this is not working , can anybody give me the explaination please