Java | Postorder + Suffix sum
Do postorder traversal (Left - Right - Root)\n root will contain sum of its subtree + root.val\n If root original val == root.val / count, then increment answer
* Do **postorder** traversal (Left - Right - Root)\n* `root` will contain sum of its subtree + `root.val`\n* If root original val == `root.val / count`, then increment answer\n* return pair of **root.val** (sum of its subtree) and **count** (number of nodes in it subtree)\n```\nclass Solution {\n\n    public int averageOfSubtree(TreeNode root) {\n        ans = 0;\n        solve(root, 0);\n        return ans;\n    }\n\n    int ans = 0;\n\n    private int[] solve(TreeNode root, int count) {\n        if (root == null) {\n            return new int[] { 0, 0 };\n        }\n        int left[] = solve(root.left, count);\n        int right[] = solve(root.right, count);\n        int temp = root.val;\n        root.val += (left[0] + right[0]);\n        count = (left[1] + right[1]) + 1;\n        if (temp == (root.val / count))  ans++; \n        return new int[] { root.val, count };\n    }\n}\n```\n
[]