Meeting room scheduling

$times = [[1, 4], [5, 6], [8, 9], [2, 6]];
$x = [];
$rooms = 0;

foreach ($times as $time) {
  for ($i = $time[0]; $i<= $time[1]; $i++) {
    if (!isset($x[$i])) {
      $x[$i] = 0;
    }

    $x[$i]++;

    if ($x[$i] > $rooms) {
      $rooms = $x[$i];
    }
  }
}
    
index