You are viewing a single comment's thread. Return to all comments →
My Java 8 Solution
static int getLength(SinglyLinkedListNode node) { int length = 0; while (node != null) { node = node.next; length++; } return length; } static int findMergeNode(SinglyLinkedListNode head1, SinglyLinkedListNode head2) { int length1 = getLength(head1); int length2 = getLength(head2); while (length1 > length2) { head1 = head1.next; length1--; } while (length2 > length1) { head2 = head2.next; length2--; } while (head1 != head2) { head1 = head1.next; head2 = head2.next; } return head1.data; }
Seems like cookies are disabled on this browser, please enable them to open this website
Find Merge Point of Two Lists
You are viewing a single comment's thread. Return to all comments →
My Java 8 Solution