Average of Levels in Binary Tree
Return the average value of nodes on each level in the tree.
Examples
Input: [3,9,20,null,null,15,7]
Output: [3,14.5,11]
Input: [1]
Output: [1]
Hints
Utilize a queue to implement BFS, tracking nodes level by level.
For each level, calculate the sum of node values and count the number of nodes to compute the average.
Handle edge cases such as an empty tree or a tree with a single node explicitly to ensure robustness.
Average of Levels in Binary Tree
Return the average value of nodes on each level in the tree.