1120. Maximum Average Subtree
TreeDepth-First SearchBinary Tree
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.
Preparing judge…