Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

95% of /prog/ can't write this simple program

Name: Anonymous 2008-05-12 15:10

You are given an array of 1001 integers. The integers are in random order, but you know each of the integers is between 1 and 1000 (inclusive). 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.

Task: In your language of choice, write an function to find the repeated number without using auxiliary storage.

Name: Anonymous 2008-05-12 15:32

How can we solve this when you haven't specified which number occurs twice?!
And should the function find the first or the last occurence of the repeated number?

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List