def test_solution(in_list, out_list): head = to_linked_list(in_list) assert to_list(Solution().reverseList(head)) == out_list
def test_solution(input_array, expected_array): head = to_linked_list(input_array) middle_node = Solution().middleNode(head) result_array = to_list(middle_node) assert result_array == expected_array
def test_solution(in_list, expected_out_list): head = to_linked_list(in_list) Solution().reorderList(head) assert to_list(head) == expected_out_list
def test_solution(head_lst, result_lst): head_node = to_linked_list(head_lst) result_node = Solution().deleteDuplicates(head_node) assert to_list(result_node) == result_lst
def test_reverse(in_list, out_list): head = to_linked_list(in_list) result = reverse(head) assert to_list(result) == out_list
def test_solution(lists, expected_list): heads = [to_linked_list(x) for x in lists] assert to_list(Solution().mergeKLists(heads)) == expected_list
def test_merge_lists(l1_array, l2_array, expected_list): l1 = to_linked_list(l1_array) l2 = to_linked_list(l2_array) assert to_list(Solution().mergeLists(l1, l2)) == expected_list
def test_to_list(): head = ListNode(1, ListNode(2, ListNode(3, None))) assert to_list(head) == [1, 2, 3]