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.
current1=llist1
current2=llist2
flag=True
while current1 and current2 and flag is True:
if current1.data != current2.data:
flag=False
current1=current1.next
current2=current2.next
if flag is True and current1==current2:
return 1
else:
return 0
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
An unexpected error occurred. Please try reloading the page. If problem persists, please contact support@hackerrank.com
Compare two linked lists
You are viewing a single comment's thread. Return to all comments →
Python solution:
def compare_lists(llist1, llist2):