| Conditions | 5 |
| Paths | 8 |
| Total Lines | 20 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 20 | private static function helper(int $start, int $end): array |
||
| 21 | { |
||
| 22 | $ans = []; |
||
| 23 | if ($start > $end) { |
||
| 24 | $ans[] = null; |
||
| 25 | } |
||
| 26 | for ($i = $start; $i <= $end; $i++) { |
||
| 27 | $lefts = self::helper($start, $i - 1); |
||
| 28 | $rights = self::helper($i + 1, $end); |
||
| 29 | foreach ($lefts as $left) { |
||
| 30 | foreach ($rights as $right) { |
||
| 31 | $root = new TreeNode($i); |
||
| 32 | $root->left = $left; |
||
| 33 | $root->right = $right; |
||
| 34 | $ans[] = $root; |
||
| 35 | } |
||
| 36 | } |
||
| 37 | } |
||
| 38 | |||
| 39 | return $ans; |
||
| 40 | } |
||
| 42 |