Pregunta de entrevista de WorkForce Software

Scan integer array for duplicates and return them.

Respuesta de la entrevista

Anónimo

17 may 2022

Create HashSet, check if integer is already in set, if so it's a duplicate so add it to results array, if not add it to the set. One optimization I missed is you can just print the integer once by using a map where you flag the number if you've already printed it. That would be n time complexity, mine was technically 2n, but still just fine.