两个数组的交集
vector<int> Intersection(vector<int>& Vector1, vector<int>& Vector2) { sort(Vector1.begin(), Vector1.end()); sort(Vector2.begin(), Vector2.end()); int index1 = 0, index2 = 0; vector<int> Vector; while (index1 < Vector1.size() && index2 < Vector2.size()) { if (Vector1[index1] == Vector2[index2]) { if (Vector.size() ==0 || Vector[Vector.size() - 1] == Vector1[index1]) Vector.push_back(Vector1[index1]); ++index1; ++index2; } else Vector1[index1] < Vector2[index2] ? ++index1 : ++index2; } return Vector; }