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)
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
def test_recursive(): for i, ll in enumerate(linkedlist2): assert compareListNode(recursive().reverseList(ll), answer[i]) == True
def test_iterative(): for i, ll in enumerate(linkedlist): assert compareListNode(iterative().reverseList(ll), answer[i]) == True
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)
def test_naive(): for head, ans in testcase: assert compareListNode(naive().insertionSortList(head), ans)
def test_naive(): for lst, k, ans in testcase: assert compareListNode(naive().rotateRight(listNodeConverter(lst), k), listNodeConverter(ans))
def test_twopointer(): for i, ll in enumerate(linkedlist): assert compareListNode( TwoPointer().removeNthFromEnd(listNodeConverter(ll), n[i]), answer[i]) == True
def test_hashtable(): for i, ll in enumerate(linkedlist): assert compareListNode( HashTable().removeNthFromEnd(listNodeConverter(ll), n[i]), answer[i]) == True