I have been asked this question in a job interview and I have been wondering about the right answer.
You have an array of numbers from 0 to n-1, one o
int a[] = {2,1,2,3,4}; int b[] = {0}; for(int i = 0; i < a.size; i++) { if(a[i] == a[i+1]) { //duplicate found //copy it to second array b[i] = a[i]; } }