755. Find the Level of Tree with Minimum Sum
Given the root of a binary tree, where each node contains a numerical value, determine the level of the tree that has the minimum sum of node values among all levels.
If multiple levels have the same minimum sum, return the lowest level.
The root node is at level 1, and the level of any other node is defined as its distance from the root + 1.
Example 1:

Input: root = [45, 10, 5, 25, 70, 12]
Output: 2
Explanation: The tree is represented as root = [45, 10, 5, 25, 70, 12].
Level 1: 45 (sum = 45)
Level 2: 10 + 5 = 15 (sum = 15)
Level 3: 25 + 70 + 12 = 107 (sum = 107)
Among these, level 2 has the minimum sum of 15, so the output is 2.
Example 2:

Input: root = [40, 20, 15, null, null, 30]
Output: 3
Explanation: The tree is represented as root = [40, 20, 15, null, null, 30].
Level 1: 40 (sum = 40)
Level 2: 20 + 15 = 35 (sum = 35)
Level 3: 30 (sum = 30)
Since level 3 has the smallest sum (30), the output is 3.
Now Your Turn!
Pick the correct output for the given inputInput: root = [8, null, 8, null, 8]
Still unsure what the problem is asking ?
Let’s go through a few more examples, step by step, to make it clearer.
Constraints:
- The number of nodes in the tree is in the range [1, 100000]
- Each node's value is between 1 and 109