def do(self, func): '''todo''' lns = ( ( [2, 4, 3], [5, 6, 4], [7, 0, 8]), ( [0], [0], [0]), ( [1, 8], [0], [1, 8]), ( [5], [5], [0, 1]), ) for l1, l2, l3 in lns: l = func(utils.array2listnode(l1), utils.array2listnode(l2)) self.assertEqual(utils.listnode2array(l), l3)
def runAlgorithm(lists: List[int]): return listnode2array(s.swapPairs(array2listnode(lists)))
def runAlgorithm(l1, l2): # Convert list to a linked list before passing the params. # After calling the solution function, re-convert the linked node value to a list value. return listnode2array( s.addTwoNumbers(array2listnode(l1), array2listnode(l2)))
def runAlgorithm(lists: List[int], k: int): return listnode2array(s.reverseKGroup(array2listnode(lists), k))
def runAlgorithm(l1, l2): return listnode2array(s.mergeTwoLists(array2listnode(l1), array2listnode(l2)))
def runAlgorithm(array, n): # Convert list to a linked list before passing the params. # After calling the solution function, re-convert the linked node value to a list value. return listnode2array(s.removeNthFromEnd(array2listnode(array), n))
def runAlgorithm(lists: List[List[int]]): return listnode2array(s.mergeKLists([array2listnode(l) for l in lists]))