Conditions | 3 |
Paths | 3 |
Total Lines | 10 |
Code Lines | 7 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
52 | private static function dfs(?TreeNode $node, int $depth, array & $ans): void |
||
53 | { |
||
54 | if ($node instanceof TreeNode) { |
||
55 | if ($depth === count($ans)) { |
||
56 | array_push($ans, $node->val); |
||
57 | } else { |
||
58 | $ans[$depth] = max($ans[$depth], $node->val); |
||
59 | } |
||
60 | self::dfs($node->left, $depth + 1, $ans); |
||
61 | self::dfs($node->right, $depth + 1, $ans); |
||
62 | } |
||
65 |