How To Find A Deleted Value In Array ?

Today i had an interview and i was asked a question.

Suppose you have an array with 1 to 10000 numbers. If one number is replaced by -1 at an index let say 546 . This array is given to me and i am asked to find out which was the number replaced by -1.

My answer was it is impossible to tell the number which is replaced by -1 when i got the array with replaced number.

can anyone tell me if my answer was correct ?
It would depend on whether or not you have the previous array or if there were any -1s in the array before it got changed. In the most general case, I would agree with you.
I asked from them if i get some info about previous array they told no this is the only array you have. so i guess i got it right :) thanks for reply
Unless they wanted you to try and see how the bits 'used' to be,like with some data recovery software that sees of a bit is closer to 0 than 1 or vice versa and tries to guess the previous value. But, that's probably outside the scope of the interview...right?
yes i dont think so they were going for that :)
Topic archived. No new replies allowed.