|
-
March 20th, 2003, 09:55 AM
#1
Finding duplicates in an array
Hi I am trying to solve this puzzle:
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?
Its easy to solve it using secondary array of 100 integers however I am looking for a way to do it without using aux array.
Any ideas?
Thanks.
RS
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|