I have this problem:
I want to iterate and compare each item of array1 against each item of array2, both arrays have the same lenght. When the value of both items coincide I store the value j in my indexOfInterest[] array for later use.
This is the code that I use, works well but its extremely slow comparing large arrays (thousands of items), can anyone help me in implement an efficient algorithm for this task.
int i,j;
int counter = [array1 count];
int indexOfInterest[counter];
for (i = 0; i < counter; i++) {
for (j = 0; j < counter; j++) {
if ([[array1 objectAtIndex:i] intValue] == [[array2 objectAtIndex:j]intValue] ) {
indexOfInterest[i] = j;
}
}
}