(root, max)
| 18 | }; |
| 19 | |
| 20 | const dfs = (root, max) => { |
| 21 | const left = diameterOfTree(root.left, max); |
| 22 | const right = diameterOfTree(root.right, max); |
| 23 | |
| 24 | const diameter = left + right; |
| 25 | max[0] = Math.max(max[0], diameter); |
| 26 | |
| 27 | const height = Math.max(left, right); |
| 28 | |
| 29 | return height + 1; |
| 30 | }; |
no test coverage detected