コード例 #1
0
        public void LinkedListShouldReverse_WithRecursion()
        {

            var originLists = ListNodeHelpers.CreateLinkedList(new int[5] { 1, 2, 3, 4, 5 });
            var result = ListNodeHelpers.CreateLinkedList(new int[5] { 5, 4, 3, 2, 1 });
            ListNodeHelpers.ListToString(ReverseListWithRecursion(originLists)).ShouldBe(ListNodeHelpers.ListToString(result));

        }
コード例 #2
0
        public void LinkedListSwapNodeInPairs_WithNormalCase()
        {
            var originLists = ListNodeHelpers.CreateLinkedList(new int[4] {
                1, 2, 3, 4
            });
            var result = ListNodeHelpers.CreateLinkedList(new int[4] {
                2, 1, 4, 3
            });

            ListNodeHelpers.ListToString(SwapNodeInPairsWithRecursion(originLists)).ShouldBe(ListNodeHelpers.ListToString(result));
        }