public void Test3() { ListNode l2 = new ListNode(1); l2.next = new ListNode(2); l2.next.next = new ListNode(4); ListNode l1 = null; ListNode result = MergeTwoLists(l1, l2); LinkedListHelper.PrintList(result); LinkedListHelper.CheckSorted(result); }
public void Example1() { var head = new ListNode(1); head.next = new ListNode(2); head.next.next = new ListNode(3); head.next.next.next = new ListNode(4); head.next.next.next.next = new ListNode(5); LinkedListHelper.PrintList(head); var result = ReverseBetween(head, 2, 4); LinkedListHelper.PrintList(result); }
public void Test0() { ListNode l1 = new ListNode(1); l1.next = new ListNode(4); l1.next.next = new ListNode(5); var lists = new[] { l1 }; var result = MergeKLists(lists); LinkedListHelper.PrintList(result); LinkedListHelper.CheckSorted(result); }
public void TestExample() { // 1->2->6->3->4->5->6 var head = new ListNode(1); head.next = new ListNode(2); head.next.next = new ListNode(6); head.next.next.next = new ListNode(3); head.next.next.next.next = new ListNode(4); head.next.next.next.next.next = new ListNode(5); head.next.next.next.next.next.next = new ListNode(6); LinkedListHelper.PrintList(head, "Original: "); head = RemoveElements(head, 6); LinkedListHelper.PrintList(head, "Removed: "); }
public void TestDeleteAtStartMiddleEnd() { // 1->2->6->3->4->5->6 var head = new ListNode(6); head.next = new ListNode(6); head.next.next = new ListNode(6); head.next.next.next = new ListNode(3); head.next.next.next.next = new ListNode(6); head.next.next.next.next.next = new ListNode(6); head.next.next.next.next.next.next = new ListNode(6); LinkedListHelper.PrintList(head, "Original: "); head = RemoveElements(head, 6); LinkedListHelper.PrintList(head, "Removed: "); }
public void Test6() { ListNode l1 = new ListNode(1); l1.next = new ListNode(2); l1.next.next = new ListNode(3); ListNode l2 = new ListNode(4); l2.next = new ListNode(5); l2.next.next = new ListNode(6); //var lists = new ListNode[] { null, l1, null, l2, null }; var lists = new ListNode[] { null, l1, null, null, null, l2, null }; var result = MergeKLists(lists); LinkedListHelper.PrintList(result); LinkedListHelper.CheckSorted(result); }
public void Test5() { ListNode l1 = new ListNode(25); l1.next = new ListNode(26); l1.next.next = new ListNode(42); l1.next.next.next = new ListNode(51); ListNode l2 = new ListNode(1); l2.next = new ListNode(3); l2.next.next = new ListNode(4); l2.next.next.next = new ListNode(5); l2.next.next.next.next = new ListNode(26); l2.next.next.next.next.next = new ListNode(37); ListNode result = MergeTwoLists(l1, l2); LinkedListHelper.PrintList(result); LinkedListHelper.CheckSorted(result); }
public void Test1() { ListNode l1 = new ListNode(1); l1.next = new ListNode(4); l1.next.next = new ListNode(5); ListNode l2 = new ListNode(1); l2.next = new ListNode(3); l2.next.next = new ListNode(4); ListNode l3 = new ListNode(2); l3.next = new ListNode(6); var lists = new [] { l1, l2, l3 }; var result = MergeKLists(lists); LinkedListHelper.PrintList(result); LinkedListHelper.CheckSorted(result); }