Back to course home
0% completed
Vote For New Content
Path Sum III (medium)
Problem Statement
Given the root
of a binary tree and an integer targetSum
, return the count
of number of paths in the tree where the sum of the values along the path equals targetSum
.
A path can start
and end
at any node, but it must go downward, meaning it can only travel from parent nodes to child nodes.`
Examples
Example 1:
- Input: targetSum =
10
, root =[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
1
/ \
2 3
/ \ / \
4 5 6 7
/ \ /
8 9 10
- Expected Output:
3
- Justification: The paths that sum to 10 are:
.....
.....
.....
Like the course? Get enrolled and start learning!
On this page