Conditions | 4 |
Paths | 4 |
Total Lines | 13 |
Code Lines | 7 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
11 | public static function maxDepth(TreeNode $root = null): int |
||
12 | { |
||
13 | if ($root === null) { |
||
14 | return 0; |
||
15 | } |
||
16 | if ($root->left === null) { |
||
17 | return self::maxDepth($root->right) + 1; |
||
18 | } |
||
19 | if ($root->right === null) { |
||
20 | return self::maxDepth($root->left) + 1; |
||
21 | } |
||
22 | |||
23 | return max(self::maxDepth($root->left), self::maxDepth($root->right)) + 1; |
||
24 | } |
||
49 |