Took this as a challenge and made this out! Not sure if this is the best way or not. Untested.
PHP Code:
int[] GetUniqueIndexesFromIntegerArray(int[] array, int maxsize)
{
int count = 0;
int[] indexes = new int[maxsize+1];
for(int i = 0; i < maxsize; i++)
{
for(int j = 0; j < maxsize; j++)
{
if(i == j)
{
if(j == maxsize-1)
{
indexes[count++] = i;
break;
}
continue;
}
else if(array[i] == array[j])
{
break;
}
else if(j == maxsize-1)
{
indexes[count++] = i;
}
}
}
return indexes;
}
int[] GetUniqueIndexesFromStringArray(char[][] strings, int maxsize)
{
int count = 0;
int[] indexes = new int[maxsize+1];
for(int i = 0; i < maxsize; i++)
{
for(int j = 0; j < maxsize; j++)
{
if(i == j)
{
if(j == maxsize-1)
{
indexes[count++] = i;
break;
}
continue;
}
else if(strcmp(strings[i], strings[j]) == 0) // case sensitive.
{
break;
}
else if(j == maxsize-1)
{
indexes[count++] = i;
}
}
}
return indexes;
}
__________________