You are viewing a single comment's thread. Return to all comments →
JAVA code static boolean compareLists(SinglyLinkedListNode head1, SinglyLinkedListNode head2) {
SinglyLinkedListNode tmp1 = head1; SinglyLinkedListNode tmp2 = head2 ; boolean isSame= true; while(tmp1!=null && tmp2 !=null){ if(tmp1.data != tmp2.data){ isSame=false; break; } tmp1=tmp1.next; tmp2=tmp2.next; } if(tmp1!=null || tmp2!=null){ isSame=false; } return isSame; }
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 →
JAVA code static boolean compareLists(SinglyLinkedListNode head1, SinglyLinkedListNode head2) {