#C12149. Deepest Level Sum of a Binary Tree

    ID: 41544 Type: Default 1000ms 256MiB

Deepest Level Sum of a Binary Tree

Deepest Level Sum of a Binary Tree

You are given a binary tree. Your task is to determine the maximum depth (d) of the tree and compute the sum (S) of all node values that are at the deepest level (i.e., at level (d)).

The maximum depth is defined as the number of nodes along the longest path from the root node down to the farthest leaf node. If the tree is empty, then both (d) and (S) are 0.

inputFormat

A single line containing space-separated values representing the level-order traversal of the binary tree. Each token is either an integer or the string null (in LaTeX: (\texttt{null})) indicating a missing node.

outputFormat

Output two space-separated integers on a single line: the maximum depth (d) and the sum (S) of all node values at the deepest level.## sample

1 2 3 4 5 6 7 8 null null null 9
4 17