Consider this function:
int mistery(const vector<int>& A, const vector<int>& B) {
int n = A.size();
int res = 0;
for (int i = 0; i < n; ++i)
for (int j = 0; j < n; ++j)
if (A[i] != A[j]) res = max(res, B[i] + B[j]);
return res;
}
Implement an alternative function, with the same name, return type and parameters, that computes the same, but as efficiently as possible.
Assume that @A@ and @B@ have the same number @n@ of elements, that @n@ is between 1 and , and that the elements of the vectors are all between 1 and .
You only need to submit the required procedure; your main program will be ignored.