class Solution(): def insert_into_doubly_ll(self, head, last, node): if head == None: head = last = node head.next = last.next = None else: last.next = node node.prev = last last = node return head, last def merge(self, l1, l2): if not l1: return l2 if not l2: return l1 head = None last = None while l1 and l2: #print("Showing merged list") #self.show(head) if l1.data
Good explanation
Table of Contents
0:00 Problem Statement
0:40 Solution - Merge Sort Algorithm
3:00 Solution - Split Function
5:10 Solution - Merge Function
9:29 Code
class Solution():
def insert_into_doubly_ll(self, head, last, node):
if head == None:
head = last = node
head.next = last.next = None
else:
last.next = node
node.prev = last
last = node
return head, last
def merge(self, l1, l2):
if not l1:
return l2
if not l2:
return l1
head = None
last = None
while l1 and l2:
#print("Showing merged list")
#self.show(head)
if l1.data