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
Nesta página do site você pode assistir ao vídeo on-line Merge two sorted linked lists [HackerRank] | LinkedList | Data Structure | Interview duração hora minuto segundo em boa qualidade , que foi baixado pelo usuário Coding Cart 21 Fevereiro 2020, compartilhe o link com seus amigos e conhecidos, no youtube este vídeo já foi visto 3,193 vezes e gostou 46 espectadores. Boa visualização!