I think you need to be more explicit in the range/constraints. One can define a flag array containing 0 if a certain number is not yet visited, and 1 once it's visited. The next time we see a number whose flag has 1, that's basically the repeated number.
It would be interesting as well if the space complexity is constant (not O(n) or whatever) like the following link:
On 8/15/06, Lego Haryanto <[EMAIL PROTECTED]> wrote:
Is the number set random? Or is it sequential from 1 to n-1?
On 8/15/06, shashi_genius <[EMAIL PROTECTED] > 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.--
Fear of the LORD is the beginning of knowledge (Proverbs 1:7)
--
Fear of the LORD is the beginning of knowledge (Proverbs 1:7)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/algogeeks
-~----------~----~----~----~------~----~------~--~---