(root, max, total)
| 18 | } |
| 19 | |
| 20 | const dfs = (root, max, total) => { |
| 21 | const isGood = max <= root.val |
| 22 | if (isGood) total[0]++; |
| 23 | |
| 24 | max = Math.max(max, root.val); |
| 25 | |
| 26 | count(root.left, max, total); |
| 27 | count(root.right, max, total); |
| 28 | } |
| 29 | |
| 30 | /** |
| 31 | * https://leetcode.com/problems/count-good-nodes-in-binary-tree/ |