Lightweight (suboptimal) C++ solution (autofilled with mine)


#1

This replaced official “Lightweight” a second after I submitted it and passed all the tests, fascinating.

vector<int> Solution::solve(vector<int> &A, vector<int> &B) {
    vector<int> res;
    sort(A.begin(), A.end());
    for (int i=0; i<B.size(); i++) {
        int x = B[i]+1;
        while (true) {
            //cout << "i:"<<i<<" B[i]="<< B[i] << " testing "<<x<<endl;
            auto it = lower_bound(A.begin(), A.end(), x);
            if (it==A.end() || *it!=x) {
                res.push_back(x);
                break;
            } else {
                //cout << "bound: " << *it << endl;
            }
            x++;
        }
    }
    return res;
}