Back to course home
0% completed
Solution: Path Sum III
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!
Table of Contents
Contents are not accessible
Contents are not accessible
Contents are not accessible
Contents are not accessible
Contents are not accessible