Esempio n. 1
0
 def test_case1(self):
     nums = [1, 2, 3, 4, 5]
     m = 2
     n = 4
     answer = [1, 4, 3, 2, 5]
     result = self.sol.reverseBetween(ListNode.parseArray2List(nums), m, n)
     self.assertEqual(answer, ListNode.parseList2Array(result))
Esempio n. 2
0
 def test_case1(self):
     l1 = [2, 4, 3]
     l2 = [5, 6, 4]
     answer = [7, 0, 8]
     result = self.sol.addTwoNumbers(ListNode.parseArray2List(l1),
                                     ListNode.parseArray2List(l2))
     self.assertEqual(answer, ListNode.parseList2Array(result))
Esempio n. 3
0
 def test_case2(self):
     l1 = [2]
     l2 = [8, 6, 4]
     answer = [0, 7, 4]
     result = self.sol.addTwoNumbers(ListNode.parseArray2List(l1),
                                     ListNode.parseArray2List(l2))
     self.assertEqual(answer, ListNode.parseList2Array(result))
 def test_case1(self):
     nums = [0, 1]
     nodes = ListNode.parseArray2List(nums)
     #node at index 0 (node.val = 0)
     answer = [1]
     result = self.sol.deleteNode(nodes)
     self.assertEqual(answer, ListNode.parseList2Array(nodes))
Esempio n. 5
0
 def test_case3(self):  # ====>
     l1 = [5]
     l2 = [5]
     answer = [0, 1]
     result = self.sol.addTwoNumbers(ListNode.parseArray2List(l1),
                                     ListNode.parseArray2List(l2))
     self.assertEqual(answer, ListNode.parseList2Array(result))
 def test_case1(self):
     nums = [1,2,3,4,5]
     m =2
     n = 4
     answer = [1,4,3,2,5]
     result = self.sol.reverseBetween(ListNode.parseArray2List(nums),m, n)
     self.assertEqual(answer, ListNode.parseList2Array(result))
Esempio n. 7
0
 def test_case2(self): #====>
     nums = [1]
     x = 0
     answer = [1]
     result = self.sol.partition(ListNode.parseArray2List(nums), x)
     self.assertEqual(answer, ListNode.parseList2Array(result))
 def test_case1(self):
     nums = [1,2,3,4,5]
     answer = [5,4,3,2,1]
     result = self.sol.reverseList(ListNode.parseArray2List(nums))
     prin( ListNode.parseList2Array(result))
     self.assertEqual(answer, ListNode.parseList2Array(result))
 def test_case4(self):
     nums = [1,2]
     k = 1
     answer = [1,2]
     result = self.sol.reverseKGroup(ListNode.parseArray2List(nums), k)
     self.assertEqual(answer, ListNode.parseList2Array(result))
Esempio n. 10
0
 def test_case1(self):
     nums = [1,2,3,4]
     answer = [1,4,2,3]
     root = ListNode.parseArray2List(nums)
     self.sol.reorderList(root)
     self.assertEqual(answer, ListNode.parseList2Array(root))
Esempio n. 11
0
 def test_case3(self): # ====>
     l1 = [5]
     l2 = [5]
     answer = [0, 1]
     result = self.sol.addTwoNumbers(ListNode.parseArray2List(l1), ListNode.parseArray2List(l2))
     self.assertEqual(answer, ListNode.parseList2Array(result))
 def test_case4(self):
     nums = [1, 2]
     k = 1
     answer = [1, 2]
     result = self.sol.reverseKGroup(ListNode.parseArray2List(nums), k)
     self.assertEqual(answer, ListNode.parseList2Array(result))
Esempio n. 13
0
 def test_case3(self):
     nums = [1]
     head = ListNode.parseArray2List(nums)
     answer = [1]
     result = self.sol.sortList(head)
     self.assertEqual(answer, ListNode.parseList2Array(result))
 def test_case3(self):
     nums = [1]
     answer = [1]
     result = self.sol.deleteDuplicates(ListNode.parseArray2List(nums))
     self.assertEqual(answer, ListNode.parseList2Array(result))
Esempio n. 15
0
 def test_case1(self):
     nums = [1, 4, 3, 2, 5, 2]
     x = 3
     answer = [1, 2, 2, 4, 3, 5]
     result = self.sol.partition(ListNode.parseArray2List(nums), x)
     self.assertEqual(answer, ListNode.parseList2Array(result))
Esempio n. 16
0
 def test_case2(self):  #====>
     nums = [1]
     x = 0
     answer = [1]
     result = self.sol.partition(ListNode.parseArray2List(nums), x)
     self.assertEqual(answer, ListNode.parseList2Array(result))
Esempio n. 17
0
 def test_case2(self):
     l1 = [2]
     l2 = [8, 6, 4]
     answer = [0, 7, 4]
     result = self.sol.addTwoNumbers(ListNode.parseArray2List(l1), ListNode.parseArray2List(l2))
     self.assertEqual(answer, ListNode.parseList2Array(result))
Esempio n. 18
0
 def test_case1(self):
     l1 = [2,4,3]
     l2 = [5,6,4]
     answer = [7,0,8]
     result = self.sol.addTwoNumbers(ListNode.parseArray2List(l1),ListNode.parseArray2List(l2))
     self.assertEqual(answer, ListNode.parseList2Array(result))
Esempio n. 19
0
 def test_case1(self):
     nums = [1, 4, 3, 2, 5, 2]
     x = 3
     answer = [1, 2, 2, 4, 3, 5]
     result = self.sol.partition(ListNode.parseArray2List(nums), x)
     self.assertEqual(answer, ListNode.parseList2Array(result))
 def test_case5(self):  # ====>
     nums = [1, 2, 3]
     k = 3
     answer = [3, 2, 1]
     result = self.sol.reverseKGroup(ListNode.parseArray2List(nums), k)
     self.assertEqual(answer, ListNode.parseList2Array(result))
Esempio n. 21
0
 def test_case1(self):
     nums = [1, 2, 3, 4, 5]
     k = 2
     answer = [4, 5, 1, 2, 3]
     result = self.sol.rotateRight(ListNode.parseArray2List(nums), k)
     self.assertEqual(answer, ListNode.parseList2Array(result))
Esempio n. 22
0
 def test_case1(self):
     nums = [1, 2, 3, 4, 5]
     answer = [5, 4, 3, 2, 1]
     result = self.sol.reverseList(ListNode.parseArray2List(nums))
     prin(ListNode.parseList2Array(result))
     self.assertEqual(answer, ListNode.parseList2Array(result))
Esempio n. 23
0
 def test_case2(self):  # ========>
     nums = [1, 2, 3]
     k = 2000000000
     answer = [2, 3, 1]
     result = self.sol.rotateRight(ListNode.parseArray2List(nums), k)
     self.assertEqual(answer, ListNode.parseList2Array(result))
Esempio n. 24
0
 def test_case2(self):
     nums = [1, 0, -1, -2]
     head = ListNode.parseArray2List(nums)
     answer = [-2, -1, 0, 1]
     result = self.sol.sortList(head)
     self.assertEqual(answer, ListNode.parseList2Array(result))
 def test_case1(self):
     l1 = ListNode(0)
     l2 = ListNode(1)
     answer = [0, 1]
     result = self.sol.mergeTwoLists(l1, l2)
     self.assertEqual(answer, ListNode.parseList2Array(result))
Esempio n. 26
0
 def test_case2(self):
     input = [1, 2, 3]
     answer = [2, 1, 3]
     result = self.sol.swapPairs(ListNode.parseArray2List(input))
     self.assertEqual(answer, ListNode.parseList2Array(result))
 def test_case1(self):
     l1 = ListNode(0)
     l2 = ListNode(1)
     answer = [0, 1]
     result = self.sol.mergeTwoLists(l1, l2)
     self.assertEqual(answer, ListNode.parseList2Array(result))
Esempio n. 28
0
 def test_case2(self): #====>
     nums = [1]
     answer = [1]
     root = ListNode.parseArray2List(nums)
     self.sol.reorderList(root)
     self.assertEqual(answer, ListNode.parseList2Array(root))
 def test_case2(self):
     input = [1, 2, 3]
     answer = [2, 1, 3]
     result = self.sol.swapPairs(ListNode.parseArray2List(input))
     self.assertEqual(answer, ListNode.parseList2Array(result))
 def test_case3(self):
     nums = [1]
     answer = [1]
     result = self.sol.deleteDuplicates(ListNode.parseArray2List(nums))
     self.assertEqual(answer, ListNode.parseList2Array(result))
 def test_case5(self): # ====>
     nums = [1,2,3]
     k = 3
     answer = [3,2,1]
     result = self.sol.reverseKGroup(ListNode.parseArray2List(nums), k)
     self.assertEqual(answer, ListNode.parseList2Array(result))