• + 0 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;
    }