• + 0 comments

    My python solution:

    def flatlandSpaceStations(n, c):
        c.sort()
        distances = []
        distances.append(c[0]) # maximum distance of cities before the first station    
        distances.append(n - 1 - c[-1]) # maximum distance of cities beyond the last station
        if len(c) > 1:        
            for i in range(len(c) - 1):
                distances.append((c[i + 1] - c[i]) // 2) # maximum distance of cities between stations
        return max(distances)