shashi_genius wrote:
> There are n numbers with all (n-1) unique numbers, except for one which
> is repeating.
> Find out  the repeating number in O(n) complexity.

I would use a simple distribution count.

for (i = 0; i < n; i++)  {
   dcount[i]++;
   if (dcount[i] > 1)
      printf( "\n The repeating number is: %d", i );
}

This is way faster than sorting. I believe it is exactly O(n).
 
Adak


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/algogeeks
-~----------~----~----~----~------~----~------~--~---

Reply via email to