示例#1
0
def test_naive():
    assert compareListNode(
        naive().mergeKLists([listNodeConverter(lst) for lst in listsA1]),
        answer1)
    assert compareListNode(
        naive().mergeKLists([listNodeConverter(lst) for lst in listsB1]),
        answer2)
示例#2
0
def test_naive():
    l1 = listNodeConverter([2, 4, 3])
    l2 = listNodeConverter([5, 6, 4])
    ans = listNodeConverter([7, 0, 8])
    assert compareListNode(ans, naive().addTwoNumbers(l1, l2)) == True

    l1 = listNodeConverter([1, 8])
    l2 = listNodeConverter([0])
    ans = listNodeConverter([1, 8])
    assert compareListNode(ans, naive().addTwoNumbers(l1, l2)) == True
示例#3
0
def test_recursive():
    for i, ll in enumerate(linkedlist2):
        assert compareListNode(recursive().reverseList(ll), answer[i]) == True
示例#4
0
def test_iterative():
    for i, ll in enumerate(linkedlist):
        assert compareListNode(iterative().reverseList(ll), answer[i]) == True
示例#5
0
def test_dc():
    assert compareListNode(
        dc().mergeKLists([listNodeConverter(lst) for lst in listsA2]), answer1)
    assert compareListNode(
        dc().mergeKLists([listNodeConverter(lst) for lst in listsB2]), answer2)
示例#6
0
def test_naive():
    for head, ans in testcase:
        assert compareListNode(naive().insertionSortList(head), ans)
示例#7
0
def test_naive():
    for lst, k, ans in testcase:
        assert compareListNode(naive().rotateRight(listNodeConverter(lst), k),
                               listNodeConverter(ans))
示例#8
0
def test_twopointer():
    for i, ll in enumerate(linkedlist):
        assert compareListNode(
            TwoPointer().removeNthFromEnd(listNodeConverter(ll), n[i]),
            answer[i]) == True
示例#9
0
def test_hashtable():
    for i, ll in enumerate(linkedlist):
        assert compareListNode(
            HashTable().removeNthFromEnd(listNodeConverter(ll), n[i]),
            answer[i]) == True