Pergunta de entrevista da empresa Knight Capital

Given an array of N integers, find the missing integer.

Respostas da entrevista

Sigiloso

5 de nov. de 2010

the answer is subtract the sum from n*(n+1)/2

3

Sigiloso

20 de mar. de 2011

Is that a well-known algorithm? I don't know how you could ever have figured that out. I would have sorted the array and iterated until I got to the missing integer.

Sigiloso

13 de mai. de 2010

Iterate through array, keeping a sum of the values. Subtract the final answer from n*(n-1)/2

2