This question is there are basically three ways online, one is to use a hash table to record the number of elements and elements appear, and the other is to use violence to do, This question I have no idea, so basic is to learn other people's ideas to write, because have been using c coding is not clear so there are a lot of places, hash tables are also less likely to use the wording on c ++.
Knowledge Point: hash table (Hash table, hash table) is the basis of the key (Key value) and direct access to the data structure.
(Method One: violence Solution)
class Solution { public : Vector < int > INTERSECT (Vector < int > & nums1, Vector < int > & nums2) { Vector < int > RET; // Create a recording element of the intersection of two numerical arrays for (Vector < int > Iterator IT1 = nums1.begin :: ();! nums1.end IT1 = (); IT1 ++ ) { for (Vector < int > :: = nums2.begin Iterator IT2 (); nums2.end IT2 = ();! IT2 ++ ) { IF (IT1 * == * IT2) { ret.push_back ( *it1); // When two arrays with the same elements, this element in ret, and then these two elements empty, so the next time you are looking for without error * IT1 = - 10086 ; * IT2 = - 10085 ; } } } return RET; } };