def test_case2( self ): # ===> this case means that node value can be negative, and the purpose is to search a single path root = TreeNode.generate_bt_from_string('2,#,-1,null,#') answer = 2 result = self.sol.maxPathSum(root) self.assertEqual(answer, result)
def test_case1(self): n = 22 root = TreeNode.generate_bt_from_string( "5,#,4,8,#,11,null,13,4,#,7,2,null,null,5,1,#") answer = [[5, 4, 11, 2], [5, 8, 4, 5]] result = self.sol.pathSum(root, n) self.assertEqual(answer, result)
def test_case2(self): # ===> this case means that node value can be negative, and the purpose is to search a single path root = TreeNode.generate_bt_from_string('2,#,-1,null,#') answer = 2 result = self.sol.maxPathSum(root) self.assertEqual(answer, result)
def test_case1(self): root = TreeNode.generate_bt_from_string('1,#,2,3,#') answer = 6 result = self.sol.maxPathSum(root) self.assertEqual(answer, result)
def test_case1(self): root = TreeNode.generate_bt_from_string('1,#,2,3,#') answer = 6 result = self.sol.maxPathSum(root) self.assertEqual(answer, result)