We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
For Python: Here are some "helper" classes in case you want to run/test code outside of hackerrank:
classSinglyLinkedListNode:def__init__(self,data):self.data=dataself.next=Nonedef__repr__(self):returnf"SinglyLinkedListNode({self.data})"classSinglyLinkedList:def__init__(self):self.head=Nonedefinsert_node(self,data):# find the end of the list.node=SinglyLinkedListNode(data)ifnotself.head:self.head=nodereturnptr=self.headwhileptr.next:ptr=ptr.nextptr.next=nodedef__repr__(self):lst=[]node=self.headwhilenode:lst.append(node.data)node=node.nextreturnf"SinglyLinkedList({lst})"
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Merge two sorted linked lists
You are viewing a single comment's thread. Return to all comments →
For Python: Here are some "helper" classes in case you want to run/test code outside of hackerrank: