Pergunta de entrevista da empresa Google

Find the common numbers in two text files.

Respostas da entrevista

Sigiloso

1 de ago. de 2013

Liron, HashMap is a bad choice for strings especially when you have large files since you'll have to many collisions. (There's way to many possible strings than the possible int values). I would choose at least a trie for your solution. You can still get along with hashmap in the case of numbers if the numbers don't exceed an int.

Sigiloso

4 de fev. de 2012

Considering you ment the common strings. hash every string from the first file O(n), search every string from the second file int the hash O(n).