2023-06-15 解題區►Leetcode►Medium Leetcode 1161 - Maximum Level Sum of a Binary Tree 題目 Problem# 給你一個 Binary Tree 問你能不能回傳一個最小的 depth x 其中 depth x 的所有 node 總和 y 最大 測資限制# 1≤n≤104 −105≤val≤105 想法# BFS 遍歷,要記得每個 node 的深度,當往下走訪(left, right)時,depth 要加一 建個 array sum[i] 其中 i 是圖的 depth 時間複雜度: O(n) 空間複雜度: O(n) AC Code# Copy view raw leetcode/1161.cpp delivered with ❤ by emgithub Newer Leetcode 1732 - Find the Highest Altitude Older Leetcode 530 - Minimum Absolute Difference in BST