c++||RECURSION
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 ans=0;\n    pair<int,int> solve(TreeNode *root)\n    {\n        if(root==NULL)\n        {\n            pair<int,int>p;\n            \n            return {0,0};\n        }\n        \n        pair<int,int> left=solve(root->left);\n        pair<int,int> right=solve(root->right);\n        \n        int s=left.first+right.first+root->val;\n        int a=left.second+right.second+1;\n        \n        if(round(s/a)==root->val)\n        {\n            ans++;\n        }\n        \n        pair<int,int>p1;\n        \n        \n        return {s,a};\n    }\n    int averageOfSubtree(TreeNode* root) \n    {\n        solve(root);\n        \n        return ans;\n    }\n\n    \n};\n```
['C++']