Sollicitatievraag bij WorkForce Software

Scan integer array for duplicates and return them.

Antwoord op sollicitatievraag

Anoniem

17 mei 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.