Example #1
0
def test_2():
    tree = "[1,2,null,3]"
    root = stringToTreeNode(tree)
    tree_diameter = TreeDiameter()
    diameter = tree_diameter.find_diameter(root)
    assert diameter == 2
Example #2
0
def test_null():
    tree = "[]"
    root = stringToTreeNode(tree)
    tree_diameter = TreeDiameter()
    diameter = tree_diameter.find_diameter(root)
    assert diameter == 0
Example #3
0
def test_1():
    tree = "[1, 2, 3,null,null,5,6,7,8,9,null,null,null,10,null,11]"
    root = stringToTreeNode(tree)
    tree_diameter = TreeDiameter()
    diameter = tree_diameter.find_diameter(root)
    assert diameter == 6
def test_4():
    tree = "[9,6,-3,null,null,-6,2,null,null,2,null,-6,-6,-6]"
    solution = Solution()
    root = stringToTreeNode(tree)
    max_path = solution.find_maximum_path_sum(root)
    assert max_path == 16
Example #5
0
def test():
    tree = "[1, 2, 3, 4, 5]"
    root = stringToTreeNode(tree)
    tree_diameter = TreeDiameter()
    diameter = tree_diameter.find_diameter(root)
    assert diameter == 3
def test_3():
    tree = "[2,-1]"
    solution = Solution()
    root = stringToTreeNode(tree)
    max_path = solution.find_maximum_path_sum(root)
    assert max_path == 2
def test_2():
    tree = "[1,2,3,1,3,5,6,null,null,null,null,7,8,9]"
    solution = Solution()
    root = stringToTreeNode(tree)
    max_path = solution.find_maximum_path_sum(root)
    assert max_path == 31
def test_1():
    tree = "[1, 2, 3,null,4,5,6]"
    solution = Solution()
    root = stringToTreeNode(tree)
    max_path = solution.find_maximum_path_sum(root)
    assert max_path == 16
Example #9
0
def test_2():
    tree = "[1,-2,-3,1,3,-2,null,-1]"
    test_data = "3"
    root = stringToTreeNode(tree)
    arr = stringToIntegerList(test_data)
    assert count_paths(root, arr) == 1
Example #10
0
def test_1():
    tree = "[10,5,-3,3,2,null,11,3,-2,null,1]"
    test_data = "8"
    root = stringToTreeNode(tree)
    arr = stringToIntegerList(test_data)
    assert count_paths(root, arr) == 3