コード例 #1
0
        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));
        }
コード例 #2
0
 private static SinglyLinkedListNode ConcatLists(TestSinglyLinkedList first, TestSinglyLinkedList second)
 {
     SinglyLinkedListHelper.JoinNodes(new[] { first.Last, second.Head });
     return(first.Head);
 }