-
- Notifications
You must be signed in to change notification settings - Fork 49.2k
Added max_sum_bst.py #11832
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added max_sum_bst.py #11832
Changes from 2 commits
6029b30 0d53dea 2c98313 a5d835e ec766f3 822df1d e8f1d4e 21dc6d9 0aea0f2 0a58155 421e92f 25a7ee6 f42bca1 c5b03b6 6179a8a 3f3caff ad04568 07e9c50 3be3064 ff65aa3 c2f438d 410e737 005205d b932346 3aea631 55dd178 e62a5fb 47ac98b cf1e92a 318fd22 f1c5829 cbc759b 450f10a 2baf142 906527f 50aec67 e10b4e3 a946077 4852473 136cdec e0b6bf0 40d8653 1534755 923a307 a1d76c6 ac0709d e74d24e af00d57 7d1f92a bae1df8 c2a62d9 8df7748 cb2d96e b2ebccd d290a9c 95c9f15 619aef8 File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,14 @@ | ||
| from dataclasses import dataclass | ||
| from typing import Optional | ||
| | ||
| | ||
| | ||
| @dataclass | ||
| class TreeNode: | ||
| Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please make this a https://docs.python.org/3/library/dataclasses.html Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. | ||
| val: int = 0 | ||
| left: Optional['TreeNode'] = None | ||
| right: Optional['TreeNode'] = None | ||
| left: Optional["TreeNode"] = None | ||
| right: Optional["TreeNode"] = None | ||
cclauss marked this conversation as resolved. Outdated Show resolved Hide resolved | ||
| | ||
| | ||
| def max_sum_bst(root: TreeNode) -> int: | ||
cclauss marked this conversation as resolved. Outdated Show resolved Hide resolved | ||
| """ | ||
| | @@ -40,7 +42,7 @@ | |
| """ | ||
| ans = 0 | ||
| | ||
| def solver(node: Optional[TreeNode]) -> tuple[bool, int, int, int]: | ||
| ||
| """ | ||
| Returns the maximum sum by making recursive calls | ||
| """ | ||
| | ||
Uh oh!
There was an error while loading. Please reload this page.