def test_splitListToParts_1(self):
     root = create_linklist_from_list([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
     output = [[1, 2, 3, 4], [5, 6, 7], [8, 9, 10]]
     res = Solution().splitListToParts(root, 3)
     check = []
     for node in res:
         check.append(create_list_from_linklist(node))
     self.assertListEqual(output, check)
 def test_splitListToParts(self):
     root = create_linklist_from_list([1, 2, 3])
     output = [[1], [2], [3], [], []]
     res = Solution().splitListToParts(root, 5)
     check = []
     for node in res:
         check.append(create_list_from_linklist(node))
     self.assertListEqual(output, check)
Ejemplo n.º 3
0
 def test_sortList_1(self):
     li = create_linklist_from_list([-1, 5, 3, 4, 0])
     self.assertListEqual([-1, 0, 3, 4, 5],
                          create_list_from_linklist(
                              Solution().sortList(li)))
Ejemplo n.º 4
0
 def test_sortList(self):
     self.assertListEqual([1, 2, 3, 4],
                          create_list_from_linklist(Solution().sortList(
                              create_linklist_from_list([4, 2, 1, 3]))))
Ejemplo n.º 5
0
 def test_removeZeroSumSublists(self):
     head = create_linklist_from_list([1, 2, -3, 3, 1])
     self.assertListEqual([3, 1],
                          create_list_from_linklist(
                              Solution().removeZeroSumSublists(head)))
 def test_reorderList(self):
     head = create_linklist_from_list([1, 2, 3, 4])
     Solution().reorderList(head)
     self.assertListEqual([1, 4, 2, 3], create_list_from_linklist(head))
Ejemplo n.º 7
0
 def test_removeZeroSumSublists_3(self):
     head = create_linklist_from_list([0, 0])
     self.assertListEqual([],
                          create_list_from_linklist(
                              Solution().removeZeroSumSublists(head)))
 def test_insertionSortList(self):
     head = create_linklist_from_list([4, 2, 1, 3])
     self.assertListEqual([1, 2, 3, 4],
                          create_list_from_linklist(
                              Solution().insertionSortList(head)))
 def test_insertionSortList_1(self):
     head = create_linklist_from_list([-1, 5, 3, 4, 0])
     self.assertListEqual([-1, 0, 3, 4, 5],
                          create_list_from_linklist(
                              Solution().insertionSortList(head)))
 def test_oddEvenList(self):
     head = create_linklist_from_list([1,2,3,4,5])
     result = create_list_from_linklist(Solution().oddEvenList(head))
     self.assertListEqual([1,3,5,2,4], result)
 def test_oddEvenList_1(self):
     head = create_linklist_from_list([2,1,3,5,6,4,7])
     result = create_list_from_linklist(Solution().oddEvenList(head))
     self.assertListEqual([2,3,6,7,1,5,4], result)