Given two int arrays. Find out common numbers and different numbers.
Anonymous
void findDiff (array arr1, array arr2) { unordered_set hash; unordered_set::iterator it; int i = 0, k = 0; //used to traverse both arrays in while loops while( i != arr1.end()) { if ( arr1[i] == NULL) { i++; } else hash.insert(arr1[i]); i++; } for( it = hash.begin(); it != hash.end(); it++) { if(arr[k] == NULL) { k++; } if( hash.find(arr2[k]) == hash.end()) { hash.insert(arr2[k]); k++; } else hash.erase(arr2[k]); k++; } for (it = hash.begin(); it != hash.end(); it++) { cout << it* << endl; }
Check out your Company Bowl for anonymous work chats.