An interview question.

Posted by SysAdmin on Stack Overflow See other posts from Stack Overflow or by SysAdmin
Published on 2010-04-09T07:35:06Z Indexed on 2010/04/09 7:43 UTC
Read the original article Hit count: 446

Filed under:
|
|
|

I recently came across a question somewhere

Suppose you have an array of 1001 integers. The integers are in random order, but you know each of the integers is between 1 and 1000 (inclusive). In addition, each number appears only once in the array, except for one number, which occurs twice. Assume that you can access each element of the array only once. Describe an algorithm to find the repeated number. If you used auxiliary storage in your algorithm, can you find an algorithm that does not require it?

what i am interested to know is the second part. i.e without using auxiliary storage . do you have any idea?

© Stack Overflow or respective owner

Related posts about algorithm

Related posts about c