My LeetCode grinding. Trying to do a problem a day.
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

problem.txt 509B

1234567891011121314151617181920212223
  1. Given the root of a binary tree, the level of its root is 1, the level of its children is 2, and so on.
  2. Return the smallest level X such that the sum of all the values of nodes at level X is maximal.
  3. Example 1:
  4. Input: [1,7,0,7,-8,null,null]
  5. Output: 2
  6. Explanation:
  7. Level 1 sum = 1.
  8. Level 2 sum = 7 + 0 = 7.
  9. Level 3 sum = 7 + -8 = -1.
  10. So we return the level with the maximum sum which is level 2.
  11. Note:
  12. The number of nodes in the given tree is between 1 and 10^4.
  13. -10^5 <= node.val <= 10^5