Beats 95% simple post order traversal solution c++
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:O(n)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:O(n) stack space\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    \n    int  dfs(TreeNode* r,int *c,int *cc){\n        if(r!=NULL){\n            int k=(*cc);\n            (*cc)++;\n           \n            \n            int a=dfs(r->left,c,cc);\n            int b=dfs(r->right,c,cc);\n            if((a+b+r->val)/((*cc)-k)==r->val){\n                (*c)++;\n            }\n            return a+b+r->val;\n\n\n        }\n        return 0;\n        \n    }\n    int averageOfSubtree(TreeNode* r) {\n        int cc=0;\n        int c=0;\n        dfs(r,&c,&cc);\n        return c;\n    }\n};\n```
['C++']