Post Order Traversal C++ Recursion O(n)
Each call will return sum of it\'s right and left subtree along with its node count, then the root will will handle the remaining calculations.\n\nclass Solutio
Each call will return sum of it\'s right and left subtree along with its node count, then the root will will handle the remaining calculations.\n```\nclass Solution {\npublic:\n    int averageOfSubtree(TreeNode* root) {\n        int count = 0;\n        pot(root,count);\n        return count;\n    }\n    \n    vector<int> pot(TreeNode* root, int &count){\n        if(root == NULL) return {0,0};\n        \n        vector<int> av1 = pot(root->left,count);\n        vector<int> av2 = pot(root->right,count);\n        \n        if((av1[0]+av2[0]+root->val)/(av1[1]+av2[1]+1) == root->val)\n            count++;\n        \n        return {av1[0]+av2[0]+root->val,av1[1]+av2[1]+1};\n    }\n};\n```
['Recursion', 'Binary Tree']