← ALL NOTES
Tree

437. Path Sum III

Count downward paths (any node to any descendant, not necessarily root-to-leaf) whose values sum to targetSum. The naive "try every start node, DFS every path below it" is O(n²). The clean solution…

Loading…