Pergunta de entrevista da empresa Amazon

Given an array of consecutive integers (1-100) with no reptitions, give a function that returns the missing int.

Resposta da entrevista

Sigiloso

10 de jun. de 2011

Get the expected sum Get the actual sum The difference is the missing number. Getting the expected sum is Nx(N+1)/2 --- simple algebra that I unfortunately forgot in my interview!

1