Exemplo n.º 1
0
        public void Test1()
        {
            var sharedList = new ListNode(8, new ListNode(4, new ListNode(5)));
            var listA      = new ListNode(4, new ListNode(1, sharedList));
            var listB      = new ListNode(5, new ListNode(0, new ListNode(1, sharedList)));
            var result     = solution.GetIntersectionNode(listA, listB);

            Assert.AreEqual(8, result.val);
        }
        public void GetIntersectionNode(ListNode headA, ListNode headB, ListNode expected)
        {
            var sut    = new IntersectionOfTwoLinkedLists();
            var actual = sut.GetIntersectionNode(headA, headB);

            Assert.AreEqual(expected, actual);
        }
Exemplo n.º 3
0
        public void GetIntersectionNodeTestCase2()
        {
            var listA             = CommonHelpers.GetLinkedListFromArray(new[] { 1, 51 });
            var listB             = CommonHelpers.GetLinkedListFromArray(new[] { 2, 4, 6, 51 });
            var intersectionValue = 51;

            CommonHelpers.MakeIntersection(intersectionValue, listA, listB, 1, 3);
            IntersectionOfTwoLinkedLists.GetIntersectionNode(listA, listB).Value.Should().Be(intersectionValue);
        }
Exemplo n.º 4
0
        public void GetIntersectionNodeTestCase1()
        {
            var listA             = CommonHelpers.GetLinkedListFromArray(new[] { 4, 1, 8, 4, 5 });
            var listB             = CommonHelpers.GetLinkedListFromArray(new[] { 5, 6, 1, 8, 4, 5 });
            var intersectionValue = 8;

            CommonHelpers.MakeIntersection(intersectionValue, listA, listB, 2, 3);
            IntersectionOfTwoLinkedLists.GetIntersectionNode(listA, listB).Value.Should().Be(intersectionValue);
        }