示例#1
0
文件: test_160.py 项目: luohy15/daily
def test2(Solution):
    la = arr2list([0, 9, 1, 2, 4])
    lb = arr2list([3])
    ca = la
    ca = ca.next
    ca = ca.next
    ca = ca.next
    cb = lb
    cb.next = ca
    assert Solution().getIntersectionNode(la, lb).val == 2
示例#2
0
文件: test_160.py 项目: luohy15/daily
def test1(Solution):
    la = arr2list([4, 1])
    lb = arr2list([5, 0, 1, 8, 4, 5])
    ca = la
    ca = ca.next
    cb = lb
    cb = cb.next
    cb = cb.next
    cb = cb.next
    ca.next = cb
    assert Solution().getIntersectionNode(la, lb).val == 8
示例#3
0
文件: test_83.py 项目: luohy15/daily
def checkSolution(arr_in, arr_out):
    list_in = arr2list(arr_in)
    list_out = Solution().deleteDuplicates(list_in)
    cur = list_out
    for a in arr_out:
        assert cur.val == a
        cur = cur.next
    assert cur == None
示例#4
0
def checkFunc(arr_in, arr_out, func, k):
    list_in = arr2list(arr_in)
    list_out = func(list_in, k)
    cur = list_out
    for a in arr_out:
        assert cur.val == a
        cur = cur.next
    assert cur == None
示例#5
0
def test1():
    arr = [3, 2, 0, -4]
    _list = arr2list(arr)
    cur = _list
    dst = cur.next
    while cur.next:
        cur = cur.next
    src = cur
    src.next = dst
    assert Solution().hasCycle(_list) == True
示例#6
0
文件: test_23.py 项目: luohy15/daily
def test1(Solution):
    lists = [[1, 4, 5], [1, 3, 4], [2, 6]]
    li = []
    for l in lists:
        li.append(arr2list(l))
    assert list2arr(Solution().mergeKLists(li)) == [1, 1, 2, 3, 4, 4, 5, 6]
示例#7
0
def test3(Solution):
    assert list2arr(Solution().addTwoNumbers(arr2list([9,9,9,9,9,9,9]), arr2list([9,9,9,9]))) == [8,9,9,9,0,0,0,1]
示例#8
0
def test2(Solution):
    assert list2arr(Solution().addTwoNumbers(arr2list([0]), arr2list([0]))) == [0]
示例#9
0
def test1(Solution):
    assert list2arr(Solution().addTwoNumbers(arr2list([2,4,3]), arr2list([5,6,4]))) == [7,0,8]
示例#10
0
def test2():
    arr = [1, 2]
    _list = arr2list(arr)
    _list.next.next = _list
    assert Solution().hasCycle(_list) == True
示例#11
0
文件: test_206.py 项目: luohy15/daily
def test1(Solution):
    arr = [1, 2, 3, 4, 5]
    assert list2arr(Solution().reverseList(arr2list(arr))) == [5, 4, 3, 2, 1]
示例#12
0
文件: test_160.py 项目: luohy15/daily
def test3(Solution):
    la = arr2list([2, 6, 4])
    lb = arr2list([1, 5])
    assert Solution().getIntersectionNode(la, lb) == None
示例#13
0
def test4(Solution):
    assert list2arr(Solution().oddEvenList(arr2list([1, 2]))) == [1, 2]
示例#14
0
def test3(Solution):
    assert list2arr(Solution().oddEvenList(arr2list([]))) == []
示例#15
0
def test2(Solution):
    assert list2arr(Solution().oddEvenList(arr2list(
        [1, 2, 3, 4, 5, 6]))) == [1, 3, 5, 2, 4, 6]
示例#16
0
文件: test_21.py 项目: luohy15/daily
def test1(Solution):
    l1 = arr2list([1, 2, 4])
    l2 = arr2list([1, 3, 4])
    assert list2arr(Solution().mergeTwoLists(l1, l2)) == [1, 1, 2, 3, 4, 4]