Problem Statement:
You’re given the pointer to the head nodes of two sorted linked lists. The data in both lists will be sorted in ascending order. Change the next pointers to obtain a single, merged linked list which also has data in ascending order. Either head pointer given may be null meaning that the corresponding list is empty.
#HackerRank #DataStructure #Interview
Sample Problem:
https://www.hackerrank.com/challenges...
Code sample:
def mergeLists(head1, head2):
p1=head1
p2=head2
if p1.data is less than p2.data: // use angle bracket sign
head=p1
t=p1
p1=p1.next
else:
head=p2
t=p2
p2=p2.next
while(p1!=None and p2!=None):
if p1.data is less than p2.data: // use angle bracket sign
t.next=p1
p1=p1.next
t=t.next
else:
t.next=p2
p2=p2.next
t=t.next
if p1==None:
t.next=p2
else:
t.next=p1
return head
For 1 : 1 Tutoring
WhatsApp contact : 7278222619
mail: jaiswalsatya93@gmail.com
You can support via UPI : sattujaiswal@okhdfcbank
Follow me on:
Whatsapp:
https://chat.whatsapp.com/LNwHGukUizj...
Facebook:
/ coderscart
Linkedin:
/ satyendra-jaiswal-903588a2
Instagram:
/ codingcart
On this page of the site you can watch the video online Merge two sorted linked lists [HackerRank] | LinkedList | Data Structure | Interview with a duration of hours minute second in good quality, which was uploaded by the user Coding Cart 21 February 2020, share the link with friends and acquaintances, this video has already been watched 3,193 times on youtube and it was liked by 46 viewers. Enjoy your viewing!