Given the root of a non-empty binary tree, return the average value of the nodes on each level in the form of an array. Answers within 10⁻⁵ of the actual answer will be accepted.
Example 1:
Input: root = [3, 9, 20, null, null, 15, 7]
Output: [3, 14.5, 11]
Explanation: Level 0: average of [3] = 3. Level 1: average of [9, 20] = 14.5. Level 2: average of [15, 7] = 11.
Example 2:
Input: root = [3, 9, 20, 15, 7]
Output: [3, 14.5, 11]
Example 3:
Input: root = [1]
Output: [1]
[1, 10⁴]-2³¹ <= Node.val <= 2³¹ - 1