http://www.leetcode.com/2010/03/here-is-phone-screening-question-from.html


vector findIntersection(vector A, vector B) {
vector intersection;
int n1 = A.size();
int n2 = B.size();
int i = 0, j = 0;
while (i < n1 && j B[j]) {
j++;
} else if (B[j] > A[i]) {
i++;
} else {
intersection.push_back(A[i]);
i++;
j++;
}
}
return intersection;
}

Advertisements