コード例 #1
0
 def test_tree2(self):
     root = TreeNode()
     root.build_from_heap([1, 2, 3])
     self.assertEqual(diameter_binary_tree(root), 2)
コード例 #2
0
 def test_tree_root_only(self):
     root = TreeNode()
     root.build_from_heap([1])
     self.assertEqual(diameter_binary_tree(root), 0)
コード例 #3
0
 def test_tree_long_left(self):
     root = TreeNode()
     root.build_from_heap([2, 3, None, 1])
     self.assertEqual(diameter_binary_tree(root), 2)
コード例 #4
0
 def test_tree1432(self):
     root = TreeNode()
     root.build_from_heap([1, 4, 3, 2])
     self.assertEqual(diameter_binary_tree(root), 3)
コード例 #5
0
 def test_minus(self):
     root = TreeNode()
     root.build_from_heap([-10, 9, 20, None, None, 15, 7])
     solution = Solution()
     self.assertEqual(solution.maxPathSum(root), 42)
コード例 #6
0
 def test_123(self):
     root = TreeNode()
     root.build_from_heap([1, 2, 3])
     solution = Solution()
     self.assertEqual(solution.maxPathSum(root), 6)
 def test_85171012(self):
     test_head = TreeNode()
     test_head.build_from_heap([8, 5, 10, 1, 7, None, 12])
     self.assertEqual(build_bst([8, 5, 1, 7, 10, 12]), test_head)