My approach is using the idea of the quest sort method:

Partition A[] into two sub array, all items in left array <= key, all items in right array > key;

if left array length modulo 3 not equal 0, then the single number in the left sub array, otherwise the single number in the right sub array.

using the recursion call to get the result.
For other similar problem, like 4 times, 5 times, 6 times etc. you just need to change the modulo to 4,5,6, etc.
here is my code for 3 times:
int findSingle(int A[], int b,int e)
{
if(eb<3)
return A[b];
int i=b,j=b+1,key= A[b],temp;
int m=b;
while(A[b]==A[e1]) // Adjust special case
{
m++;
temp= A[m];
A[m]= A[b];
A[b]= temp;
key= temp;
}
// Partition
for(; j<e; j++)
{
if(A[j] <= key)
{
i++;
temp= A[j];
A[j]= A[i];
A[i]= temp;
}
}
A[b]= A[i];
A[i]= key;
// recursion
if((ib+1)%3)
return findSingle(A,b,i+1);
else
return findSingle(A,i+1,e);
}
int singleNumber(int A[], int n)
{
return findSingle(A,0,n);
}