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 e933b87

Browse files
doc: add README
1 parent 16acdd2 commit e933b87

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

‎binary_tree/max_root_leaf_path_sum/max_root_leaf_path_sum.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,8 @@ def max_path_sum(root):
4444
The time complexity is O(n), where n is the number of nodes in the binary tree, and the space complexity
4545
is O(h), where h is the height of the binary tree in the worst-case scenario.
4646
47-
TODO:
48-
Another iteration of this problem is the Binary Tree Maximum Path Sum
49-
This problem tries to find the max path sum that mmay or may not include
50-
the root. More on this...
47+
Another permutation of this problem is the Binary Tree Maximum Path Sum
48+
This problem tries to find the maximum sum of any non-empty path that may or may not include
49+
the root. Checkout the 'max_tree_path_sum' entry in this directory to find out how to solve this problem.
5150
"""
5251

‎binary_tree/max_tree_path_sum/README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
## **Problem Statement**
2+
3+
Given the root of a binary tree, return the maximum sum of any non-empty path.
4+
5+
A path in a binary tree is defined as follows:
6+
7+
A sequence of nodes in which each pair of adjacent nodes must have an edge connecting them.
8+
A node can only be included in a path once at most.
9+
Including the root in the path is not compulsory.
10+
11+
You can calculate the path sum by adding up all node values in the path. To solve this problem, calculate the maximum path sum given the root of a binary tree so that there won’t be any greater path than it in the tree.
12+
13+
14+
### Constraints
15+
16+
> 1 ≤ Number of nodes in the tree ≤ 500.
17+
18+
> −1000 ≤ Node.value ≤ 1000

0 commit comments

Comments
(0)

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