Pergunta de entrevista da empresa Northrop Grumman

You have an array of numbers with each number having being duplicated except for one. The array is not sorted. How would you go about finding the number without a duplicate?

Respostas da entrevista

Sigiloso

10 de fev. de 2017

^That is inefficient. That is nlog(n). If you do 2 for loops first, inserting into a hashmap and incrementing when you see it again, second checking through the hashmap for the value of 1. that would be O(n) instead of O(nlogn)

Sigiloso

6 de jul. de 2016

Order the list using some kind of sorting algorithm (quick sort, merge sort, etc.) and then compare every two numbers. For the first instance of the the two numbers not being equal to each other, then the first number is the odd one out.