273. Average of Levels in Binary Tree
EasyTree
Given the root of a binary tree, return the average value of the nodes on each level in the form of an array. Answers within 10^-5 of the actual answer will be accepted.
Examples
Input: [3,9,20,null,null,15,7]
Output: [3.0,14.5,11.0]
Explanation: Level sums 3, 29, 22 over counts 1, 2, 2 give averages 3, 14.5, 11.
Constraints
- The number of nodes in the tree is in the range [1, 10^4].
- -2^31 <= Node.val <= 2^31 - 1
Loading...
Run checks all cases above. Submit evaluates all test cases.