# 2265. Count Nodes Equal to Average of Subtree ###### tags: `medium` https://leetcode.com/problems/count-nodes-equal-to-average-of-subtree/description/   這次是使用DFS(深度優先搜尋) 還有另一種BFS(廣度優先搜尋) 差別在於 DFS 使用堆疊的概念 先進的會後出 BFS 使用佇列的概念 先進的會先出 而這一題要找自己的子樹相加除於數量=root.val的 所以只要用DFS每個走過一遍 將sum=左右ROOT的值 然後除去左右的子數數量+1(ROOT自己) 寫好判斷後遞迴 最後將有符合的記住 
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up