示例#1
0
        public void TestCheckPalindrome()
        {
            LinkedList L1 = new LinkedList();

            L1.AddLast(1);
            var head = LListProblems.CheckPalindrom(L1.Head);
        }
示例#2
0
        public void TestRemoveMatchingElements()
        {
            LinkedList L1 = new LinkedList();

            L1.AddLast(2);

            LListProblems.removeAllMatchingElements(L1.Head, 2);
        }
示例#3
0
        public void TestRotateBykthNumber()
        {
            LinkedList L1 = new LinkedList();

            L1.AddLast(1);
            //L1.AddLast(2);
            //L1.AddLast(3);
            //L1.AddLast(4);
            //L1.AddLast(5);
            var head = LListProblems.RotateLinkedList(L1.Head, 99);
        }
示例#4
0
        public void TestRemoveNthNode()
        {
            LinkedList L1 = new LinkedList();

            L1.AddLast(1);
            L1.AddLast(2);
            L1.AddLast(3);
            //L1.AddLast(4);
            //L1.AddLast(5);
            var head = LListProblems.RemoveNthFromEnd(L1.Head, 3);
        }
示例#5
0
        public void TestSwapPairs()
        {
            LinkedList L1 = new LinkedList();

            L1.AddLast(1);
            L1.AddLast(2);
            L1.AddLast(3);
            L1.AddLast(4);

            var head = LListProblems.SwapPairs(L1.Head);
        }
示例#6
0
        public void TestReverseLinkedList()
        {
            LinkedList L1 = new LinkedList();

            L1.AddLast(1);
            L1.AddLast(2);
            L1.AddLast(3);
            L1.AddLast(4);
            L1.AddLast(5);

            LListProblems.ReverseLinkedList(L1.Head);
        }
示例#7
0
        public void TestGetMiddleNode()
        {
            LinkedList L1 = new LinkedList();

            L1.AddLast(1);
            L1.AddLast(2);
            L1.AddLast(3);
            L1.AddLast(4);
            L1.AddLast(5);

            ListNode middleNode = LListProblems.GetMiddleNode(L1.Head);
        }
示例#8
0
        public void TestNextGreaterNode()
        {
            LinkedList L1 = new LinkedList();

            L1.AddLast(1);
            L1.AddLast(4);
            L1.AddLast(3);
            L1.AddLast(5);
            L1.AddLast(2);

            var head = LListProblems.NextGreaterNode(L1.Head);
        }
示例#9
0
        public void TestRemoveDuplicatesFromSorted()
        {
            LinkedList L1 = new LinkedList();

            L1.AddLast(1);
            L1.AddLast(2);
            L1.AddLast(2);
            L1.AddLast(3);
            L1.AddLast(3);

            var head = LListProblems.RemoveDuplicatesFromSortedLinkedList(L1.Head);
        }
示例#10
0
        public void FindCountofConnectedComponents()
        {
            LinkedList L1 = new LinkedList();

            L1.AddLast(1);
            L1.AddLast(4);
            L1.AddLast(3);
            L1.AddLast(5);
            L1.AddLast(2);

            int[] array = { 1, 4, 3, 2 };

            var counts = LListProblems.ConnectedComponentsCounts(L1.Head, array);
        }
示例#11
0
        public void TestMethod1()
        {
            LinkedList L1 = new LinkedList();

            L1.AddLast(2);
            L1.AddLast(3);

            LinkedList L2 = new LinkedList();

            L2.AddLast(1);
            //L2.AddLast(9);

            LListProblems.AddTwoNumbers(L1.Head, L2.Head);
        }
示例#12
0
        public void TestGetInterSectionNode()
        {
            var node6 = new ListNode(6);
            var node5 = new ListNode(5); node5.next = node6;
            var node4 = new ListNode(4); node4.next = node5;

            var nodeA3 = new ListNode(3); nodeA3.next = node4;
            var nodeA2 = new ListNode(2); nodeA2.next = nodeA3;
            var nodeA1 = new ListNode(1); nodeA1.next = nodeA2;

            var nodeB2 = new ListNode(22); nodeB2.next = node4;
            var nodeB1 = new ListNode(4); nodeB1.next = node5;

            var head = LListProblems.FindNodeIntersection(nodeA1, node4);
        }
示例#13
0
        public void RemoveDuolicates()
        {
            LinkedList L1 = new LinkedList();

            L1.AddLast(1);
            L1.AddLast(1);
            L1.AddLast(1);
            L1.AddLast(2);
            L1.AddLast(2);
            L1.AddLast(3);
            //L1.AddLast(3);
            //L1.AddLast(4);

            var head = LListProblems.RemoveDuplicateNode(L1.Head);
        }
示例#14
0
        public void TestMergeTwoSortedList()
        {
            LinkedList L1 = new LinkedList();

            L1.AddLast(1);
            L1.AddLast(2);
            L1.AddLast(4);

            LinkedList L2 = new LinkedList();

            L2.AddLast(1);
            L2.AddLast(3);
            L2.AddLast(4);

            var head = LListProblems.MergeTwoSortedList(L1.Head, L2.Head);
        }