- We can use backtracking to go through all the path from root to each of the leaf nodes.
- What we need to pass down:
- need to know the contribution of cur node (10^level)
- cur path value
time: O(n) - n is the number of nodes
space: O(height)
For each node, we return: <sum of all paths, # of leaf nodes>0
time: O(n) - n is the number of nodes
space: O(height)