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.
Compare two linked lists
Compare two linked lists
Sort by
recency
|
988 Discussions
|
Please Login in order to post a comment
bool compare_lists(SinglyLinkedListNode* head1, SinglyLinkedListNode* head2) {
}
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
This is my code. JAVA
def compare_lists(llist1, llist2): current1 = llist1 current2 = llist2 while current1 and current2: if current1.data!=current2.data: return 0 current1 = current1.next current2= current2.next if current1 or current2: return 0 return 1