public void MergeTwoLists_DifferentLength_ShouldReturnMerged()
        {
            var firstLinkedList    = ListNode.CreateList(new int[] { 2, 8, 11, 15 });
            var secondLinkedList   = ListNode.CreateList(new int[] { 1, 3, 4, 12, 14, 17 });
            var expectedLinkedList = ListNode.CreateList(new int[] { 1, 2, 3, 4, 8, 11, 12, 14, 15, 17 });

            var result = MergeTwoListsImplementation.MergeTwoLists(firstLinkedList, secondLinkedList);

            Assert.True(result.Equals(expectedLinkedList) && expectedLinkedList.Equals(result));
        }
        public void MergeTwoLists_EmptyTree_ShouldReturnMerged()
        {
            var firstLinkedList    = ListNode.CreateList(new int[] { 1, 2, 4 });
            var secondLinkedList   = ListNode.CreateList(null);
            var expectedLinkedList = ListNode.CreateList(new int[] { 1, 2, 4 });

            var result = MergeTwoListsImplementation.MergeTwoLists(firstLinkedList, secondLinkedList);

            Assert.True(result.Equals(expectedLinkedList) && expectedLinkedList.Equals(result));
        }
        public void MergeKListsTest2()
        {
            ListNode[] lists =
            {
                ListNode.CreateList(new int[] { 1, 4, 5 }),
                ListNode.CreateList(new int[] { 1, 3, 4 }),
                ListNode.CreateList(new int[] { 2, 6 })
            };
            ListNode expected = ListNode.CreateList(new int[] { 1, 1, 2, 3, 4, 4, 5, 6 });

            Solution solution = new Solution();
            var      actual   = solution.MergeKLists(lists);

            Assert.IsTrue(ListNode.AreEqual(expected, actual));
        }
        public void RemoveNthFromEndTest()
        {
            int[] input = { 1, 2, 3, 4, 5 };
            int   n     = 2;

            int[]    expected     = { 1, 2, 3, 5 };
            ListNode inputNode    = ListNode.CreateList(input);
            ListNode expectedNode = ListNode.CreateList(expected);

            Solution solution = new Solution();
            var      actual   = solution.RemoveNthFromEnd(inputNode, n);

            if (ListNode.AreEqual(expectedNode, actual) == false)
            {
                Assert.Fail();
            }
        }