Pergunta de entrevista da empresa IBM

You have an unsorted array of numbers from 0-100 except one number is missing. Write an algorithm to find the missing number.

Resposta da entrevista

Sigiloso

7 de nov. de 2016

Sort and traverse until you find gap of over 1: O(nlogn) Bitarray of 100 numbers: O(n) time but O(n) extra space Summing all the numbers to S' and comparing this to full sum S appears to be the best solution as it gives linear execution time: Missing Number = S-S'