Beispiel #1
0
 def test_8(self):
    expected = [8339, 6819]
    actual = addTwoHugeNumbers(
       listToLinkedList([2309]),
       listToLinkedList([8339, 4510])
    ).toList()
    self.assertEqual(actual, expected)
Beispiel #2
0
 def test_7(self):
    expected = [1, 0, 0, 0, 0, 0, 0]
    actual = addTwoHugeNumbers(
       listToLinkedList([1]),
       listToLinkedList([9999, 9999, 9999, 9999, 9999, 9999])
    ).toList()
    self.assertEqual(actual, expected)
Beispiel #3
0
 def test_5(self):
    expected = [1234, 123, 0]
    actual = addTwoHugeNumbers(
       listToLinkedList([0]),
       listToLinkedList([1234, 123, 0])
    ).toList()
    self.assertEqual(actual, expected)
Beispiel #4
0
 def setUp(self):
     self.example1 = {
         'l1': listToLinkedList([1, 2, 3]),
         'l2': listToLinkedList([4, 5, 6])
     }
     self.example2 = {
         'l1': listToLinkedList([1, 1, 2, 4]),
         'l2': listToLinkedList([0, 3, 5])
     }
Beispiel #5
0
 def setUp(self):
    self.example1 = {
       'a': listToLinkedList([9876, 5432, 1999]),
       'b': listToLinkedList([1, 8001])
    }
    self.example2 = {
       'a': listToLinkedList([123, 4, 5]),
       'b': listToLinkedList([100, 100, 100])
    }
Beispiel #6
0
 def test_12(self):
     expected = [
         -815817641, -780990573, -670826849, -426491047, -404817961,
         242026249, 437929670, 520408640, 731519938
     ]
     actual = mergeTwoLinkedLists(
         listToLinkedList(
             [-780990573, -670826849, -404817961, 242026249, 731519938]),
         listToLinkedList([-815817641, -426491047, 437929670,
                           520408640])).toList()
     self.assertEqual(actual, expected)
 def test_5(self):
     expected = [123, 456, 789]
     actual = removeKFromList(listToLinkedList([123, 456, 789, 0]),
                              0).toList()
     self.assertEqual(actual, expected)
 def test_3(self):
     expected = None
     actual = removeKFromList(listToLinkedList([1000, 1000]), 1000)
     self.assertEqual(actual, expected)
 def setUp(self):
     self.example1 = {'l': listToLinkedList([3, 1, 2, 3, 4, 5]), 'k': 3}
     self.example2 = {'l': listToLinkedList([1, 2, 3, 4, 5, 6, 7]), 'k': 10}
Beispiel #10
0
 def test_11(self):
     expected = [-1, -1, -1, 0, 0, 0, 1, 1, 1]
     actual = mergeTwoLinkedLists(listToLinkedList([-1, -1, 0, 1]),
                                  listToLinkedList([-1, 0, 0, 1,
                                                    1])).toList()
     self.assertEqual(actual, expected)
Beispiel #11
0
 def test_10(self):
     expected = [-1000000000, 1, 1000000000]
     actual = mergeTwoLinkedLists(
         listToLinkedList([1]), listToLinkedList([-1000000000,
                                                  1000000000])).toList()
     self.assertEqual(actual, expected)
Beispiel #12
0
 def test_9(self):
     expected = [0, 2]
     actual = mergeTwoLinkedLists(listToLinkedList([0]),
                                  listToLinkedList([2])).toList()
     self.assertEqual(actual, expected)
Beispiel #13
0
 def test_7(self):
     expected = [1, 1, 4]
     actual = mergeTwoLinkedLists(listToLinkedList([1, 1, 4]),
                                  listToLinkedList([])).toList()
     self.assertEqual(actual, expected)
Beispiel #14
0
 def test_3(self):
     expected = [2, 3, 5, 10, 15, 20, 40]
     actual = mergeTwoLinkedLists(listToLinkedList([5, 10, 15, 40]),
                                  listToLinkedList([2, 3, 20])).toList()
     self.assertEqual(actual, expected)