| Conditions | 8 |
| Paths | 16 |
| Total Lines | 20 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 9 | public static function findMissingRanges(array &$nums, int $lower, int $upper): array |
||
| 10 | { |
||
| 11 | $ans = []; |
||
| 12 | if (empty($nums)) { |
||
| 13 | return $ans; |
||
| 14 | } |
||
| 15 | foreach ($nums as $num) { |
||
| 16 | if ($num > $lower) { |
||
| 17 | $ans[] = $lower . ($num - 1 > $lower ? ('->' . ($num - 1)) : ''); |
||
| 18 | } |
||
| 19 | if ($num === $upper) { |
||
| 20 | return $ans; |
||
| 21 | } |
||
| 22 | $lower = $num + 1; |
||
| 23 | } |
||
| 24 | if ($lower <= $upper) { |
||
| 25 | $ans[] = $lower . ($upper > $lower ? ('->' . $upper) : ''); |
||
| 26 | } |
||
| 27 | |||
| 28 | return $ans; |
||
| 29 | } |
||
| 67 |