leetle

Daily challenge for 2026-04-01

456. Tree Node Depth Sum

Given the root of a binary tree, return the sum of the values of all nodes at the maximum depth. The depth of the root node is 1.

Example:
Input: root = {"val": 1, "left": {"val": 2, "left": {"val": 4}, "right": {"val": 5}}, "right": {"val": 3, "left": {"val": 6}, "right": {"val": 7}}}
Output: 22
Explanation: The maximum depth is 3. The nodes at depth 3 are 4, 5, 6, and 7. Their sum is 4 + 5 + 6 + 7 = 22.

Run this challenge interactively in Python or JavaScript when the app loads.