Skip to content
Merged
Changes from 2 commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
6029b30
Added new algorithm
1227haran Oct 6, 2024
0d53dea
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 6, 2024
2c98313
Updated changes
1227haran Oct 6, 2024
a5d835e
Merge branch 'max_sum_binary_tree' of https://github.com/1227haran/Py…
1227haran Oct 6, 2024
ec766f3
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 6, 2024
822df1d
Updated filename
1227haran Oct 6, 2024
e8f1d4e
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 6, 2024
21dc6d9
Updated code
1227haran Oct 6, 2024
0aea0f2
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 6, 2024
0a58155
Updated the code
1227haran Oct 6, 2024
421e92f
Merge branch 'max_sum_binary_tree' of https://github.com/1227haran/Py…
1227haran Oct 6, 2024
25a7ee6
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 6, 2024
f42bca1
Updated code
1227haran Oct 6, 2024
c5b03b6
Updated merge conflicts
1227haran Oct 6, 2024
6179a8a
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 6, 2024
3f3caff
Updated the code
1227haran Oct 6, 2024
ad04568
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 6, 2024
07e9c50
Updated code
1227haran Oct 6, 2024
3be3064
Merge branch 'max_sum_binary_tree' of https://github.com/1227haran/Py…
1227haran Oct 6, 2024
ff65aa3
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 6, 2024
c2f438d
Updated the code
1227haran Oct 6, 2024
410e737
Merge branch 'max_sum_binary_tree' of https://github.com/1227haran/Py…
1227haran Oct 6, 2024
005205d
Updated code
1227haran Oct 6, 2024
b932346
Updated code
1227haran Oct 6, 2024
3aea631
Updated code
1227haran Oct 6, 2024
55dd178
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 6, 2024
e62a5fb
Updated the code
1227haran Oct 6, 2024
47ac98b
Merge branch 'max_sum_binary_tree' of https://github.com/1227haran/Py…
1227haran Oct 6, 2024
cf1e92a
Updated code
1227haran Oct 6, 2024
318fd22
Updated code
1227haran Oct 6, 2024
f1c5829
Updated code
1227haran Oct 6, 2024
cbc759b
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 6, 2024
450f10a
Updated code
1227haran Oct 6, 2024
2baf142
Merge branch 'max_sum_binary_tree' of https://github.com/1227haran/Py…
1227haran Oct 6, 2024
906527f
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 6, 2024
50aec67
Updated code
1227haran Oct 6, 2024
e10b4e3
updated
1227haran Oct 6, 2024
a946077
Merge branch 'max_sum_binary_tree' of https://github.com/1227haran/Py…
1227haran Oct 6, 2024
4852473
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 6, 2024
136cdec
Updated code
1227haran Oct 7, 2024
e0b6bf0
Merge branch 'max_sum_binary_tree' of https://github.com/1227haran/Py…
1227haran Oct 7, 2024
40d8653
Updated code
1227haran Oct 7, 2024
1534755
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 7, 2024
923a307
Updated code
1227haran Oct 7, 2024
a1d76c6
Merge branch 'max_sum_binary_tree' of https://github.com/1227haran/Py…
1227haran Oct 7, 2024
ac0709d
Updated code
1227haran Oct 7, 2024
e74d24e
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 7, 2024
af00d57
Updated code
1227haran Oct 7, 2024
7d1f92a
Merge branch 'max_sum_binary_tree' of https://github.com/1227haran/Py…
1227haran Oct 7, 2024
bae1df8
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 7, 2024
c2a62d9
Updated code
1227haran Oct 7, 2024
8df7748
Merge branch 'max_sum_binary_tree' of https://github.com/1227haran/Py…
1227haran Oct 7, 2024
cb2d96e
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 7, 2024
b2ebccd
Apply suggestions from code review
cclauss Oct 7, 2024
d290a9c
Update maximum_sum_bst.py
cclauss Oct 7, 2024
95c9f15
def max_sum_bst(root: TreeNode | None) -> int:
cclauss Oct 7, 2024
619aef8
def solver(node: TreeNode | None) -> tuple[bool, int, int, int]:
cclauss Oct 7, 2024
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions data_structures/binary_tree/maximum_sum_bst.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ def max_sum_bst(root: "TreeNode" | None) -> int:
ans: int = 0



def solver(node: "TreeNode" | None) -> tuple[bool, int, int, int]:
"""
Returns the maximum sum by making recursive calls
Expand All @@ -56,7 +55,7 @@ def solver(node: "TreeNode" | None) -> tuple[bool, int, int, int]:
nonlocal ans

if not node:
return True, INT_MAX, INT_MIN, 0 # Valid BST, min, max, sum
return True, INT_MAX, INT_MIN, 0 # Valid BST, min, max, sum

is_left_valid, min_left, max_left, sum_left = solver(node.left)
is_right_valid, min_right, max_right, sum_right = solver(node.right)
Expand Down
Loading