C++ || DFS ✅ || Easiest Approach 🔥|| No extra computation💡
\nIf you learn/found something new please upvote \uD83D\uDC4D\n\n\n---\n# Code\n\nclass Solution {\n    int dfs(TreeNode* root, int &sum, int &count){\n        
```\nIf you learn/found something new please upvote \uD83D\uDC4D\n```\n\n---\n# Code\n```\nclass Solution {\n    int dfs(TreeNode* root, int &sum, int &count){\n        if(root == NULL){\n            sum = 0, count = 0;\n            return 0;\n        }\n\n        int sum1 = 0, count1 = 0, sum2 = 0, count2 = 0;\n        int ans1 = dfs(root->left, sum1, count1);\n        int ans2 = dfs(root->right, sum2, count2);\n\n        int ans = ans1+ans2;\n        sum = sum1+sum2+root->val;\n        count = count1+count2+1;\n        int avg = (sum/(double)count);\n\n        if(avg == root->val)\n            ans++;\n\n        return ans;\n    }\npublic:\n    int averageOfSubtree(TreeNode* root) {\n        int sum, count;\n\n        return dfs(root, sum, count);\n    }\n};\n```
['Depth-First Search', 'Binary Tree', 'C++']