c++ || O(N) || faster than 98% || EASY TO UNDERSTAND
class Solution {\npublic:\n    int count=0;\n    pair average(TreeNode root)\n    {\n        if(root==NULL)\n        {\n            pair p=make_pair(0,0);\n    
class Solution {\npublic:\n    int count=0;\n    pair<int,int> average(TreeNode* root)\n    {\n        if(root==NULL)\n        {\n            pair<int,int> p=make_pair(0,0);\n            return p;\n        }\n        \n        pair<int,int> left=average(root->left);\n        pair<int,int> right=average(root->right);\n        \n        int sum=left.first+right.first+root->val;\n        int num=left.second+right.second+1;\n        \n        if(sum/num==root->val)\n            count++;\n        pair<int,int> ans;\n        ans.first=sum;\n        ans.second=num;\n        return ans;\n    }\n    int averageOfSubtree(TreeNode* root) {\n        average(root);\n        return count;\n    }\n};``
['Recursion', 'C', 'C++']