Add unit tests to binary_tree_path_sum.py (#11833)
* test: Add unit tests * test: Add successful tests in binaree_tree_path_sum * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update binary_tree_path_sum.py * Update binary_tree_path_sum.py * Update binary_tree_path_sum.py --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Maxim Smolskiy <mithridatus@mail.ru>
This commit is contained in:
@@ -50,6 +50,26 @@ class BinaryTreePathSum:
|
|||||||
>>> tree.right.right = Node(10)
|
>>> tree.right.right = Node(10)
|
||||||
>>> BinaryTreePathSum().path_sum(tree, 8)
|
>>> BinaryTreePathSum().path_sum(tree, 8)
|
||||||
2
|
2
|
||||||
|
>>> BinaryTreePathSum().path_sum(None, 0)
|
||||||
|
0
|
||||||
|
>>> BinaryTreePathSum().path_sum(tree, 0)
|
||||||
|
0
|
||||||
|
|
||||||
|
The second tree looks like this
|
||||||
|
0
|
||||||
|
/ \
|
||||||
|
5 5
|
||||||
|
|
||||||
|
>>> tree2 = Node(0)
|
||||||
|
>>> tree2.left = Node(5)
|
||||||
|
>>> tree2.right = Node(5)
|
||||||
|
|
||||||
|
>>> BinaryTreePathSum().path_sum(tree2, 5)
|
||||||
|
4
|
||||||
|
>>> BinaryTreePathSum().path_sum(tree2, -1)
|
||||||
|
0
|
||||||
|
>>> BinaryTreePathSum().path_sum(tree2, 0)
|
||||||
|
1
|
||||||
"""
|
"""
|
||||||
|
|
||||||
target: int
|
target: int
|
||||||
|
|||||||
Reference in New Issue
Block a user