public int FindMergeNode_ForTwoLists_ReturnsDataFromFirstSharedNode( int[] firstIndices, int[] secondIndices, int[] sharedIndices ) { TestSinglyLinkedList onlyFirst = SinglyLinkedListHelper.CreateLinkedList(firstIndices); TestSinglyLinkedList onlySecond = SinglyLinkedListHelper.CreateLinkedList(secondIndices); TestSinglyLinkedList onlyShared = SinglyLinkedListHelper.CreateLinkedList(sharedIndices); SinglyLinkedListNode firstHead = ConcatLists(onlyFirst, onlyShared); SinglyLinkedListNode secondHead = ConcatLists(onlySecond, onlyShared); return(MergePoint.FindMergeNode(firstHead, secondHead)); }
private static SinglyLinkedListNode ConcatLists(TestSinglyLinkedList first, TestSinglyLinkedList second) { SinglyLinkedListHelper.JoinNodes(new[] { first.Last, second.Head }); return(first.Head); }