Beats 100%||c++ solution||easy
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\n/**\n * Definition for a binary tree node.\n * struct TreeNode {\n *     int val;\n *     TreeNode *left;\n *     TreeNode *right;\n *     TreeNode() : val(0), left(nullptr), right(nullptr) {}\n *     TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n *     TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {}\n * };\n */\nclass Solution {\npublic:\n    int res = 0;\n\n    pair<int,int> porder(TreeNode* &root,int sum,int count)\n    {\n        if(root == 0) return {0,0};\n\n        auto l = porder(root->left,sum,count);\n        auto r = porder(root->right,sum,count);\n\n        sum = l.first + root->val + r.first;\n        count = l.second + 1 + r.second;\n\n        if(sum / count == root->val) res++;\n        return {sum,count};\n    }\n\n    int averageOfSubtree(TreeNode* root) {\n        porder(root,0,0);\n        return res;\n    }\n};\n```
['C++']