← Tree Recursion

Pattern Recognition Drill

#92 — Path sum

Easy Advanced Trees

The Problem

Is there a root-to-leaf path that sums to a target?

What approach would you use?

Think about it before scrolling down.

Key Signals

Tree Recursion

Recurse with target - node.val. At leaf: return target == node.val. O(n).

Common Trap

Must check at leaf nodes, not at null nodes. A leaf has no children.

← #91 #93 →