原题题目
代码实现(首刷自解)
class Solution {
public:vector<int> arraysIntersection(vector<int>& arr1, vector<int>& arr2, vector<int>& arr3) {
int ptr1 = 0,ptr2 = 0,ptr3 = 0;vector<int> ret;while(ptr1 != arr1.size()){
auto arr2_iter = lower_bound(arr2.begin()+ptr2,arr2.end(),arr1[ptr1]);auto arr3_iter = lower_bound(arr3.begin()+ptr3,arr3.end(),arr1[ptr1]);if(arr2_iter == arr2.end() || arr3_iter == arr3.end()) break;if(*arr2_iter == arr1[ptr1] && *arr3_iter == arr1[ptr1])ret.emplace_back(arr1[ptr1]);++ptr1;ptr2 = arr2_iter - arr2.begin();ptr3 = arr3_iter - arr3.begin();}return ret;}
};