You are viewing a single comment's thread. Return to all comments →
Don't know if this is optimized or not but this is my solution in C++
int flatlandSpaceStations(int n, vector<int> c) { if (c.size() == n) { return 0; } else { sort(c.begin(),c.end()); int res = 0; for (int i = 1; i < c.size(); i++) { res = max(res, (c[i] - c[i-1]) / 2); } res = max(res, n - c[c.size()-1] - 1); res = max(res, c[0]); return res; } }
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 →
Don't know if this is optimized or not but this is my solution in C++