题目:
题解:
class Solution:def findFrequentTreeSum(self, root: TreeNode) -> List[int]:cnt = Counter()def dfs(node: TreeNode) -> int:if node is None:return 0sum = node.val + dfs(node.left) + dfs(node.right)cnt[sum] += 1return sumdfs(root)maxCnt = max(cnt.values())return [s for s, c in cnt.items() if c == maxCnt]