public void IsPalindromeTest_5()
        {
            int[]    nodes = { 1, 2, 3, 4, 5, 3, 2, 1 };
            ListNode head  = ListNodeHelper.CreateLinkedListByArray(nodes);

            Assert.IsTrue(false == t190.IsPalindrome(head));
        }
        public void MiddleNodeTest_2()
        {
            int[]    nodes = { 1, 2, 3, 4, 5, 6 };
            ListNode list  = ListNodeHelper.CreateLinkedListByArray(nodes);

            Assert.IsTrue(4 == t867.MiddleNode(list).val);
        }
        public void RemoveElementsTest_5()
        {
            int[]    nodes  = { 6, 6, 6, 6, 6, 6 };
            ListNode lst    = ListNodeHelper.CreateLinkedListByArray(nodes);
            ListNode result = t190.RemoveElements(lst, 6);

            Assert.IsTrue(result == null);
        }
        public void RemoveElementsTest_6()
        {
            int[]    nodes  = { 1, 2, 2, 1 };
            ListNode lst    = ListNodeHelper.CreateLinkedListByArray(nodes);
            ListNode result = t190.RemoveElements(lst, 2);

            int[] resultArr = ListNodeHelper.GetElementsFromLinkedList(result);
            int[] expect    = { 1, 1 };
            Assert.IsTrue(CompareHelper.CompareArrays(expect, resultArr));
        }
Beispiel #5
0
        public void DeleteDuplicatesTest_single()
        {
            int[]    list = { 1 };
            ListNode head = ListNodeHelper.CreateLinkedListByArray(list);

            t83.DeleteDuplicates(head);
            int[] result = ListNodeHelper.GetElementsFromLinkedList(head);
            int[] expect = { 1 };
            Assert.IsTrue(CompareHelper.CompareArrays(result, expect));
        }
Beispiel #6
0
        public void AddTwoNumbersTest_2()
        {
            int[]    nums1 = { 6, 7, 8, 9, 9 };
            int[]    nums2 = { 1, 2, 3 };
            ListNode lst1  = ListNodeHelper.CreateLinkedListByArray(nums1);
            ListNode lst2  = ListNodeHelper.CreateLinkedListByArray(nums2);

            int[] expect = { 7, 9, 1, 0, 0, 1 };
            int[] res    = ListNodeHelper.GetElementsFromLinkedList(m02.AddTwoNumbers(lst1, lst2));

            Assert.IsTrue(CompareHelper.CompareArrays(expect, res));
        }