示例#1
0
def test_1():
    l = [4, 5, 1, 9]
    ll = create_linked_list(l)
    starting_node_val = 5
    starting_node = ll
    while starting_node.val != starting_node_val:
        starting_node = starting_node.next
    new_ll = create_linked_list([4, 1, 9])
    deleteNode(starting_node)
    assert (ll == new_ll)
示例#2
0
def test_2():
    l = create_linked_list([1, 2, 2, 1])
    assert (is_palindrome(l) == True)
示例#3
0
def test_1():
    l = create_linked_list([1, 2])
    assert (is_palindrome(l) == False)
示例#4
0
def test_2():
    l = create_linked_list([1])
    assert (has_cycle(l) == False)
示例#5
0
def test_2():
    ll = create_linked_list([1, 2, 3, 4, 5])
    expected_result = create_linked_list([5, 4, 3, 2, 1])
    assert (reverse(ll) == expected_result)
示例#6
0
def test_1():
    ll = create_linked_list([1, 2])
    expected_result = create_linked_list([2, 1])
    assert (reverse(ll) == expected_result)
示例#7
0
def test_3():
    ll1 = create_linked_list([2])
    ll2 = create_linked_list([1])
    expected_result = create_linked_list([1, 2])
    assert (merge(ll1, ll2) == expected_result)
示例#8
0
def test_1():
    ll1 = create_linked_list([1, 2, 4])
    ll2 = create_linked_list([1, 3, 4])
    expected_result = create_linked_list([1, 1, 2, 3, 4, 4])
    assert (merge(ll1, ll2) == expected_result)
def test_4():
    ll = create_linked_list([1, 2])
    expected_result = create_linked_list([2])
    assert (remove_node(ll, 2) == expected_result)
def test_2():
    ll = create_linked_list([1])
    expected_result = None
    assert (remove_node(ll, 1) == expected_result)