Search⌘ K
AI Features

Solution: Sum Root to Leaf Numbers

Let's solve the Sum Root to Leaf Numbers problem using the Tree Depth-First Search pattern.

Statement

Given the root node root of a binary tree where each node contains a single digit, treat every root to leaf path as a base 1010 number formed by concatenating the digits along that path from root to leaf.

Return the sum of all such numbers across every root to leaf path in ...