Beispiel #1
0
 def __init__(self):
     super(MergeKSortedListsTestCases, self).__init__()
     self.__add_test_case__(
         "Test 1", self.get_lists(),
         to_linkedlist([1, 2, 2, 3, 4, 5, 8, 9, 10, 12, 14]))
     self.__add_test_case__("Test 2", [], None)
     self.__add_test_case__(
         "Test 3", [to_linkedlist([-2, -1, -1, -1]),
                    to_linkedlist([])], to_linkedlist([-2, -1, -1, -1]))
    def gen_list2():
        head = to_linkedlist([1, 2, 3, 4, 5, 6])
        cur = head

        while cur.next:
            cur = cur.next

        cur.next = head.next
        return head, cur.next
 def __init__(self):
     super(LinkedPalinTestCases, self).__init__()
     self.__add_test_case__('Test 1', to_linkedlist(['a', 'a', 'b', 'a', 'a']), True)
     self.__add_test_case__('Test 2', to_linkedlist(['a', 'a', 'b', 'b', 'a', 'a']), True)
     self.__add_test_case__('Test 3', to_linkedlist(['a', 'a', 'b', 'a', 'c']), False)
     self.__add_test_case__('Test 4', to_linkedlist(['a', 'a', 'b']), False)
     self.__add_test_case__('Test 4', to_linkedlist(['a', 'a']), True)
     self.__add_test_case__('Test 4', to_linkedlist(['a']), True)
     self.__add_test_case__('Test 4', to_linkedlist([]), True)
    def __init__(self):

        super(RotateListTestCases, self).__init__()
        self.__add_test_case__('Test 1',
                               (to_linkedlist([1, 2, 3, 4, 5, 6, 7]), 2),
                               to_linkedlist([6, 7, 1, 2, 3, 4, 5]))
        self.__add_test_case__('Test 2',
                               (to_linkedlist([1, 2, 3, 4, 5, 6, 7]), 9),
                               to_linkedlist([6, 7, 1, 2, 3, 4, 5]))
        self.__add_test_case__('Test 2', (to_linkedlist([]), 0),
                               to_linkedlist([]))
Beispiel #5
0
 def __init__(self):
     super(OddEvenLinkedlistTestCases, self).__init__()
     self.__add_test_case__("Test 1", l2l.to_linkedlist([1, 2, 3, 4, 5, 6]),
                            l2l.to_linkedlist([1, 3, 5, 2, 4, 6]))
Beispiel #6
0
 def get_lists(self):
     res = []
     res.append(to_linkedlist([2, 2, 3, 4]))
     res.append(to_linkedlist([1, 5, 8, 10]))
     res.append(to_linkedlist([9, 12, 14]))
     return res
Beispiel #7
0
 def __init__(self):
     super(RmDuplicatesSortedListTestCases, self).__init__()
     self.__add_test_case__("Test 1", l2l.to_linkedlist([1, 1, 2]),
                            l2l.to_linkedlist([1, 2]))
     self.__add_test_case__("Test 2", l2l.to_linkedlist([1, 1, 2, 3, 3]),
                            l2l.to_linkedlist([1, 2, 3]))
 def __init__(self):
     super(RmDuplicatesSortedListIITestCases, self).__init__()
     self.__add_test_case__('Test 1', to_linkedlist([1,2,3,3,4,4,5]), to_linkedlist([1,2,5]))
     self.__add_test_case__('Test 2', to_linkedlist([1,1,1,2,2,3]), to_linkedlist([3]))
     self.__add_test_case__('Test 3', to_linkedlist([]), to_linkedlist([]))
Beispiel #9
0
 def __init__(self):
     super(PartitionListTestCases, self).__init__()
     self.__add_test_case__('Test 1', (to_linkedlist([1,4,3,2,5,2]), 3), (to_linkedlist([1,2,2,4,3,5])))