You are viewing a single comment's thread. Return to all comments →
Swift
func flatlandSpaceStations(n: Int, c: [Int]) -> Int { var cities = c cities.sort() // First var result = cities.first! if cities.count > 1 { // Mid for index in 0..<cities.count-1 { let c1 = cities[index] let c2 = cities[index + 1] if c2 - c1 > 1 { result = max(result, (c2 - c1)/2) } } } // Last result = max(result, n - cities.last! - 1) return result }
Seems like cookies are disabled on this browser, please enable them to open this website
Flatland Space Stations
You are viewing a single comment's thread. Return to all comments →
Swift