Easiest Approach || C++ || 4ms
Intuition\n Describe your first thoughts on how to solve this problem. \nThe Problem is straightforward so we can think of an algorithm by which we can know sum
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThe Problem is straightforward so we can think of an algorithm by which we can know sum of subtree and no. of nodes for every subtree of the given Tree. \n# Approach\n<!-- Describe your approach to solving the problem. -->\n-> We will use post order travesal to traverse the tree and find sum for every subtree.\n-> We will make use of refernce variable so that we can know no. of nodes present in every subtree at each level.\n> We will backtrack and apply codition to get answer .\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\nO(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: int ans =0 ;\nint help(TreeNode* root,int &n){\n     if(root==NULL){return 0 ;}\n    int x =0 ,y =0 ,n1=0,n2=0;\n    x = help(root->left,n1) ;\n    y = help(root->right,n2) ;\n        n+=(n1+n2+1) ;\n        if((x+y+root->val)/n == root->val){ans++; }\n       // cout<<n<<" "<<"*"<<root->val<<" " ;\n        return root->val + x + y;\n}\n    int averageOfSubtree(TreeNode* root) {\n        ans =0 ; int n =0 ;\n        int k = help(root,n) ;\n        return ans ;\n\n    }\n};\n```
['C++']