Skip to content

Instantly share code, notes, and snippets.

@Jxrgxn
Created July 4, 2015 02:17
Show Gist options
  • Save Jxrgxn/cefcb77ca43e5e8caddd to your computer and use it in GitHub Desktop.
Save Jxrgxn/cefcb77ca43e5e8caddd to your computer and use it in GitHub Desktop.
-(int) compareArraysFaster
{
NSMutableArray *myArray = [myArray array];
for (element in makeAnArray)
{
myArray[element] = 1;
}
//indexes in myArray match up with element in makeAnArray
//We specified at the top is that the numbers are unique.
for (i = 1; i <= makeAnArray.length(); i++)
{
//Remeber the i here doesn't represent the numbers, it reps
//the indices of the array
if (myArray[i] == 0)
{
return i;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment