Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit b092045

Browse files
ronaldngounoupre-commit-ci[bot]MaximSmolskiy
authored
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>
1 parent 1e0d317 commit b092045

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

‎data_structures/binary_tree/binary_tree_path_sum.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,26 @@ class BinaryTreePathSum:
5050
>>> tree.right.right = Node(10)
5151
>>> BinaryTreePathSum().path_sum(tree, 8)
5252
2
53+
>>> BinaryTreePathSum().path_sum(None, 0)
54+
0
55+
>>> BinaryTreePathSum().path_sum(tree, 0)
56+
0
57+
58+
The second tree looks like this
59+
0
60+
/ \
61+
5 5
62+
63+
>>> tree2 = Node(0)
64+
>>> tree2.left = Node(5)
65+
>>> tree2.right = Node(5)
66+
67+
>>> BinaryTreePathSum().path_sum(tree2, 5)
68+
4
69+
>>> BinaryTreePathSum().path_sum(tree2, -1)
70+
0
71+
>>> BinaryTreePathSum().path_sum(tree2, 0)
72+
1
5373
"""
5474

5575
target: int

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /