@Test public void Test4() { ListNode h1 = ListNode.constructLinkedList(Arrays.asList(3)); ListNode h2 = ListNode.constructLinkedList(Arrays.asList(1)); ListNode[] lists = {h1, h2}; ListNode actual = solution.mergeKLists(lists); ListNode expected = ListNode.constructLinkedList(Arrays.asList(1, 3)); assertTrue(ListNode.isSameList(actual, expected)); }
@Test public void Test3() { int[] nums = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; ListNode head = ListNode.constructLinkedList(nums); ListNode actual = solution.swapPairs(head); int[] exps = {2, 1, 4, 3, 6, 5, 8, 7, 10, 9}; ListNode expected = ListNode.constructLinkedList(exps); assertTrue(ListNode.isSameList(actual, expected)); }
@Test public void Test3() { int[] nums = {1, 2, 3, 4, 5, 6, 7, 8, 9}; ListNode head = ListNode.constructLinkedList(nums); solution.reorderList(head); int[] exps = {1, 9, 2, 8, 3, 7, 4, 6, 5}; ListNode expected = ListNode.constructLinkedList(exps); assertTrue(ListNode.isSameList(head, expected)); }
@Test public void Test4() { int[] nums = {1}; ListNode head = ListNode.constructLinkedList(nums); solution.reorderList(head); int[] exps = {1}; ListNode expected = ListNode.constructLinkedList(exps); assertTrue(ListNode.isSameList(head, expected)); }
// 1 -> 3-> 5 \ // ==> 1->2->3->4->5 // 2 -> 4 / @Test public void Test4() { int[] nums1 = {1, 3, 5}; ListNode l1 = ListNode.constructLinkedList(nums1); int[] nums2 = {2, 4}; ListNode l2 = ListNode.constructLinkedList(nums2); ListNode actual = solution.mergeTwoLists(l1, l2); int[] exps = {1, 2, 3, 4, 5}; ListNode expected = ListNode.constructLinkedList(exps); assertTrue(ListNode.isSameList(actual, expected)); }