• + 0 comments
    from bisect import bisect
    
    def flatlandSpaceStations(n, c):
        c.sort()
        max_dist = 0
        for city in range(n):
            indx = min(bisect(c, city), len(c) - 1)
            city_dist = min(abs(c[indx] - city), abs(c[max(indx - 1, 0)] - city))
            max_dist = max(max_dist, city_dist)
        return max_dist