Example #1
0
        public void DeleteDuplicatesTest_null()
        {
            ListNode head = null;

            t83.DeleteDuplicates(head);
            int[] result = ListNodeHelper.GetElementsFromLinkedList(head);
            int[] expect = { };
            Assert.IsTrue(CompareHelper.CompareArrays(result, expect));
        }
        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));
        }
Example #3
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));
        }
Example #4
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));
        }