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
En esta página del sitio puede ver el video en línea Merge two sorted linked lists [HackerRank] | LinkedList | Data Structure | Interview de Duración hora minuto segunda en buena calidad , que subió el usuario Coding Cart 21 febrero 2020, comparta el enlace con amigos y conocidos, en youtube este video ya ha sido visto 3,193 veces y le gustó 46 a los espectadores. Disfruta viendo!