1091. Maximum Average Subtree

Medium
Tree
Depth-First Search
Binary Tree

Description

Hints

Hint 1
Can you find the sum of values and the number of nodes for every sub-tree ?
Hint 2
Can you find the sum of values and the number of nodes for a sub-tree given the sum of values and the number of nodes of it's left and right sub-trees ?
Hint 3
Use depth first search to recursively find the solution for the children of a node then use their solutions to compute the current node's solution.

Statistics

Acceptance
66.9%
Submissions
109,929
Accepted
73,518