| Conditions | 5 |
| Paths | 6 |
| Total Lines | 14 |
| Code Lines | 7 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 11 | public static function insertIntoBST(?TreeNode $root, int $val): TreeNode |
||
| 12 | { |
||
| 13 | if (!$root) { |
||
| 14 | return $val ? new TreeNode($val) : new TreeNode(); |
||
| 15 | } |
||
| 16 | |||
| 17 | if ($root->val > $val) { |
||
| 18 | $root->left = self::insertIntoBST($root->left, $val); |
||
| 19 | } |
||
| 20 | if ($root->val < $val) { |
||
| 21 | $root->right = self::insertIntoBST($root->right, $val); |
||
| 22 | } |
||
| 23 | |||
| 24 | return $root; |
||
| 25 | } |
||
| 52 |