Easy C++ || Using Pair || Reuse the sum and count of SubTrees
```\nclass Solution {\npublic:\n    \n    int ans = 0;\n    \n    pair getAverageSubTree(TreeNode root, int currSum, int count)\n    {\n        if(root == NULL)
```\nclass Solution {\npublic:\n    \n    int ans = 0;\n    \n    pair<int,int> getAverageSubTree(TreeNode* root, int currSum, int count)\n    {\n        if(root == NULL) return {0,0};\n        \n        pair<int,int> left = getAverageSubTree(root -> left, currSum, count);\n        pair<int,int> right = getAverageSubTree(root -> right, currSum, count);\n        \n        currSum += root -> val + left.first + right.first;\n        count += left.second + right.second + 1;\n        \n        if((currSum/count) == root -> val) ans++;\n        return {currSum, count};\n    }\n    \n    int averageOfSubtree(TreeNode* root) \n    {\n         getAverageSubTree(root, 0, 0);\n        return ans;\n    }\n};\n
[]