def test1(): n1 = ListNode(1) n3 = ListNode(3) n2 = ListNode(2) n4 = ListNode(4) n14 = ListNode(14) n18 = ListNode(18) n7 = ListNode(7) n9 = ListNode(9) n11 = ListNode(11) n13 = ListNode(13) n1.next = n3 l1 = n1 n2.next = n4 n4.next = n14 n14.next = n18 l2 = n2 n7.next = n9 n9.next = n11 n11.next = n13 l3 = n7 lists = [l1, l2, l3] rslt = mergeKLL(lists) ListNode.print_ll(rslt)
def test3(): n1 = ListNode(1) n2 = ListNode(2) n1.next = n2 ListNode.print_ll(reorderList(n1))
def test3(): n1 = ListNode(1) n2 = ListNode(2) n2.next = n1 h = n2 rslt = mergeSort(h) ListNode.print_ll(rslt)
def test3(): n6 = ListNode(6) n7 = ListNode(7) n9 = ListNode(9) n5 = ListNode(5) n6.next = n7 n7.next = n9 ListNode.print_ll(addTwoNumbers(n6, n5, 0)) ListNode.print_ll(addTwoNumbersNoCarry(n6, n5))
def test2(): n1 = ListNode(1) n2 = ListNode(2) n3 = ListNode(3) n4 = ListNode(4) n1.next = n2 n2.next = n3 n3.next = n4 ListNode.print_ll(reorderList(n1))
def test2(): n1 = ListNode(1) n2 = ListNode(2) n3 = ListNode(3) n3.next = n2 n2.next = n1 h = n3 rslt = mergeSort(h) ListNode.print_ll(rslt)
def test3(): n1 = ListNode(1) n1a = ListNode(1) n1b = ListNode(1) n2a = ListNode(2) n2b = ListNode(2) n1.next = n1a n1a.next = n1b n1b.next = n2a n2a.next = n2b ListNode.print_ll(removeDupComp(n1))
def test2(): n1 = ListNode(1) n1a = ListNode(1) n1b = ListNode(1) n2 = ListNode(2) n3 = ListNode(3) n1.next = n1a n1a.next = n1b n1b.next = n2 n2.next = n3 ListNode.print_ll(removeDupComp(n1))
def test1(): n0 = ListNode(0) n1 = ListNode(1) n2 = ListNode(2) n3 = ListNode(3) n4 = ListNode(4) n0.next = n1 n1.next = n2 n2.next = n3 n3.next = n4 ListNode.print_ll(reorderList(n0))
def test3(): n1 = ListNode(1) n2 = ListNode(2) n3 = ListNode(3) n4 = ListNode(4) n5 = ListNode(5) n6 = ListNode(6) n1.next = n2 n2.next = n3 n3.next = n4 n4.next = n5 n5.next = n6 ListNode.print_ll(revKGrp(n1, 4))
def test4(): l1 = ListNode(1) l2 = ListNode(2) l3 = ListNode(3) l4 = ListNode(4) l5 = ListNode(5) l1.next = l2 l2.next = l3 l3.next = l4 l4.next = l5 ListNode.print_ll(l1) ListNode.print_ll(removeNtoLast(l1, 2))
def test1(): n1 = ListNode(1) n2 = ListNode(2) n3 = ListNode(3) n4 = ListNode(4) n5 = ListNode(5) n6 = ListNode(6) n1.next = n2 n2.next = n3 n3.next = n4 n4.next = n5 n5.next = n6 #ListNode.print_ll(revKGrp(n1, 2)) ListNode.print_ll(revKGroup_r(n1, 1))
def test2(): n1 = ListNode(1) n2 = ListNode(2) n3 = ListNode(3) n4 = ListNode(4) n5 = ListNode(5) n6 = ListNode(6) n1.next = n2 n2.next = n3 n3.next = n4 n4.next = n5 n5.next = n6 ListNode.print_ll(n1) ListNode.print_ll(rotateLSegment(n1, 1, 4))
def test1(): n1 = ListNode(1) n4 = ListNode(4) n3 = ListNode(3) n2a = ListNode(2) n5 = ListNode(5) n2b = ListNode(2) n1.next = n4 n4.next = n3 n3.next = n2a n2a.next = n5 n5.next = n2b ListNode.print_ll(n1) ListNode.print_ll(partitionList(n1, 3))
def test1(): n1a = ListNode(1) n1b = ListNode(1) n1c = ListNode(1) n2 = ListNode(2) n3a = ListNode(3) n3b = ListNode(3) n3c = ListNode(3) n1a.next = n1b n1b.next = n1c n1c.next = n2 n2.next = n3a n3a.next = n3b n3b.next = n3c ListNode.print_ll(removeDup(n1a))
def test1(): n1 = ListNode(1) n2 = ListNode(2) n3a = ListNode(3) n3b = ListNode(3) n4a = ListNode(4) n4b = ListNode(4) n5 = ListNode(5) n1.next = n2 n2.next = n3a n3a.next = n3b n3b.next = n4a n4a.next = n4b n4b.next = n5 ListNode.print_ll(removeDupComp(n1))
def test6(): n6 = ListNode(6) n7 = ListNode(7) n9 = ListNode(9) n5 = ListNode(5) n8 = ListNode(8) n4 = ListNode(4) n6.next = n7 n7.next = n9 n5.next = n8 n8.next = n4 ListNode.print_ll(addTwoNumbers(n6, n5, 0)) ListNode.print_ll(addTwoNumbersNoCarry(n6, n5))
def test1(): n1 = ListNode(1) n2 = ListNode(2) n3 = ListNode(3) n4 = ListNode(4) n5 = ListNode(5) n6 = ListNode(6) n1.next = n2 n2.next = n3 n3.next = n4 n4.next = n5 n5.next = n6 ListNode.print_ll(n1) ListNode.print_ll(swapPairs(n1)) print('--------------')
def test1(): n2 = ListNode(2) n4a = ListNode(4) n3 = ListNode(3) n5 = ListNode(5) n6 = ListNode(6) n4b = ListNode(4) n2.next = n4a n4a.next = n3 n5.next = n6 n6.next = n4b ListNode.print_ll(addTwoNumbers(n2, n5, 0)) ListNode.print_ll(addTwoNumbersNoCarry(n2, n5))
def test1(): n9 = ListNode(9) n4 = ListNode(4) n5 = ListNode(5) n1 = ListNode(1) n9.next = n4 n4.next = n5 n5.next = n1 n8 = ListNode(8) n7 = ListNode(7) n2 = ListNode(2) n8.next = n7 n7.next = n2 res = addTwoNums(n9, n8) ListNode.print_ll(res)
def test1(): n1 = ListNode(1) n2 = ListNode(2) n3 = ListNode(3) n4 = ListNode(4) n5 = ListNode(5) n6 = ListNode(6) n6.next = n5 n5.next = n4 n4.next = n3 n3.next = n2 n2.next = n1 h = n6 rslt = mergeSort(h) ListNode.print_ll(rslt)
def test1(): l5 = ListNode(5) l3 = ListNode(3) l7 = ListNode(7) l9 = ListNode(9) l1 = ListNode(1) l0 = ListNode(0) l8 = ListNode(8) l5.next = l3 l3.next = l7 l7.next = l9 l9.next = l1 l1.next = l0 l0.next = l8 ListNode.print_ll(insort(l5))
def test2(): n1a = ListNode(1) n1b = ListNode(1) n1c = ListNode(1) n1a.next = n1b n1b.next = n1c rslt = removeElement(n1a, 1) print(ListNode.print_ll(rslt))
def test1(): n1 = ListNode(1) n2 = ListNode(2) n3 = ListNode(3) n4 = ListNode(4) n5 = ListNode(5) n6 = ListNode(6) n7 = ListNode(7) n1.next = n2 n2.next = n3 n3.next = n4 n4.next = n5 n5.next = n6 n6.next = n7 res = oddEvenPartition(n1) ListNode.print_ll(res)
def test1(): n1 = ListNode(1) n2 = ListNode(2) n6a = ListNode(6) n3 = ListNode(3) n4 = ListNode(4) n5 = ListNode(5) n6b = ListNode(6) n1.next = n2 n2.next = n6a n6a.next = n3 n3.next = n4 n4.next = n5 n5.next = n6b rslt = removeElement(n1, 6) print(ListNode.print_ll(rslt))
def test2(): n1 = ListNode(1) n2 = ListNode(2) n1.next = n2 ListNode.print_ll(revKGrp(n1, 3))
def test3(): n1 = ListNode(1) ListNode.print_ll(n1) ListNode.print_ll(swapPairs(n1))
def test2(): n2 = ListNode(2) ListNode.print_ll(addTwoNumbers(n2, None, 0)) ListNode.print_ll(addTwoNumbersNoCarry(n2, None))
def test3(): print('----------------') head = generate_test_list3() rslt = rotateList(head, 0) ListNode.print_ll(rslt) head = generate_test_list3() rslt = rotateListLinear(head, 0) ListNode.print_ll(rslt) head = generate_test_list3() rslt = rotateList(head, 1) ListNode.print_ll(rslt) head = generate_test_list3() rslt = rotateListLinear(head, 1) ListNode.print_ll(rslt) head = generate_test_list3() rslt = rotateList(head, 2) ListNode.print_ll(rslt) head = generate_test_list3() rslt = rotateListLinear(head, 2) ListNode.print_ll(rslt) head = generate_test_list3() rslt = rotateList(head, 3) ListNode.print_ll(rslt) head = generate_test_list3() rslt = rotateListLinear(head, 3) ListNode.print_ll(rslt) head = generate_test_list3() rslt = rotateList(head, 4) ListNode.print_ll(rslt) head = generate_test_list3() rslt = rotateListLinear(head, 4) ListNode.print_ll(rslt) head = generate_test_list3() rslt = rotateList(head, 5) ListNode.print_ll(rslt) head = generate_test_list3() rslt = rotateListLinear(head, 5) ListNode.print_ll(rslt)
def test4(): n1 = ListNode(1) h = n1 rslt = mergeSort(h) ListNode.print_ll(rslt)
def test4(): n3 = ListNode(3) n4 = ListNode(4) n3.next = n4 ListNode.print_ll(addTwoNumbers(None, n3, 0)) ListNode.print_ll(addTwoNumbersNoCarry(None, n3))
def test5(): ListNode.print_ll(addTwoNumbers(None, None, 0)) ListNode.print_ll(addTwoNumbersNoCarry(None, None))