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