You are viewing a single comment's thread. Return to all comments →
Is the custom comparator too much? Maybe. But it's funnier that way.
int flatlandSpaceStations(int n, vector<int> c) { int longuest = 0; for(int i = 0; i<n; i++ ){ if(find(c.begin(), c.end(), i)==c.end()){ int closest = *min_element(c.begin(),c.end(), [&](int a, int b){ return abs(a - i) < abs(b - i); }); longuest = abs(closest-i)>longuest? abs(closest-i) : longuest; } } return longuest; }
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 →
Is the custom comparator too much? Maybe. But it's funnier that way.