Java Readable Code | 100.00% faster
\nclass Solution {\n    \n    public class NodeInfo{\n        int sum;\n        int size;\n        public NodeInfo(int sum , int size){\n            this.sum = 
```\nclass Solution {\n    \n    public class NodeInfo{\n        int sum;\n        int size;\n        public NodeInfo(int sum , int size){\n            this.sum = sum;\n            this.size = size;\n        }\n    }\n    \n    int ans = 0;\n    \n    public int averageOfSubtree(TreeNode root) \n    {\n        dfs(root);\n        return ans;\n    }\n    \n    public NodeInfo dfs(TreeNode node){\n        if(node == null)\n            return new NodeInfo(0,0);\n        \n        NodeInfo left = dfs(node.left);\n        NodeInfo right = dfs(node.right);\n        \n        int currentSum = node.val + left.sum + right.sum;\n        int currentSize = 1 + left.size + right.size;\n        \n        if(currentSum / currentSize == node.val)\n            ans++;\n        \n        return new NodeInfo(currentSum , currentSize);\n    }\n}\n```
['Depth-First Search', 'Java']