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.
def compare_lists(llist1, llist2):
c1=llist1
c2=llist2
while c1 and c2:
if c1.data==c2.data:
c1=c1.next
c2=c2.next
else:
return 0
if c1 is None and c2 is None:
return 1
return 0
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Compare two linked lists
You are viewing a single comment's thread. Return to all comments →
def compare_lists(llist1, llist2): c1=llist1 c2=llist2 while c1 and c2: if c1.data==c2.data: c1=c1.next c2=c2.next else: return 0 if c1 is None and c2 is None: return 1 return 0