C++ Easy Understanding | Recursive Solution
\nclass Solution {\npublic:\n    void findSum(TreeNode* root, int &totalSum, int &count)\n    {\n        if(root == NULL)    \n            return;\n        \n  
```\nclass Solution {\npublic:\n    void findSum(TreeNode* root, int &totalSum, int &count)\n    {\n        if(root == NULL)    \n            return;\n        \n        totalSum += root->val;\n        count++;\n        \n        findSum(root->left, totalSum, count);\n        findSum(root->right, totalSum, count);\n    }\n    \n    \n    int averageOfSubtree(TreeNode* root) \n    {\n        if(root == NULL) \n            return 0;\n        int countNodes = 0;\n        int totalSum = 0;\n        int count = 0;\n        findSum(root, totalSum, count);\n        int avg = totalSum/count;\n        if(avg == root->val)    \n            countNodes++;\n        return countNodes + averageOfSubtree(root->left) + averageOfSubtree(root->right);\n    }\n};\n```
['Recursion', 'C']