• + 0 comments
    function flatlandSpaceStations($n, $m, $c) {
        sort($c);
    
        $max = $c[0];
        for($i = 0; $i < $m - 1; $i++) {
            $dist = floor(($c[$i + 1] - $c[$i]) / 2);
            if($dist > $max) {
                $max = $dist;
            }
        }
        
        $max = max($max, $n - 1 - $c[$m - 1]);
        
        return $max;
    }