1120. Maximum Average Subtree

https://leetcode.com/problems/maximum-average-subtree

Description

Given the root of a binary tree, return the maximum average value of a subtree of that tree. Answers within 10-5 of the actual answer will be accepted.

A subtree of a tree is any node of that tree plus all its descendants.

The average value of a tree is the sum of its values, divided by the number of nodes.

Example 1:

Example 2:

Constraints:

  • The number of nodes in the tree is in the range [1, 104].

  • 0 <= Node.val <= 105

ac

Last updated

Was this helpful?