algoblazerEarly Access
LearnProblemsLeaderboard
Log inSign up

All problems

‹ Back to map
261 shown · 0/261 solved

Sum of the Deepest Nodes

Bronze
Solve problem →
2000ms256MBAdded Sep 12, 2026

You are given the root of a binary tree, root. Return the sum of the values of its deepest nodes.

The deepest nodes are the nodes at the maximum depth in the tree, where the root has depth 0. There can be more than one node at the maximum depth, and all of them are included in the sum.

Tree Encoding

Your function receives root as a TreeNode. The node type is provided for you, with val, left, and right fields.

The examples below write the tree as its level-order traversal, where null marks a missing child of a listed node and trailing nulls are omitted. That is only how the input is displayed; the decoding is done for you.

Constraints

  • The number of nodes in root is in the range [1,105][1, 10^5][1,105].
  • −104≤-10^4 \leq−104≤ Node.val ≤104\leq 10^4≤104

Details

Solved by1 person
Time limit2000ms
Memory256MB
AddedSep 12, 20267 hours ago