Question d’entretien chez Microsoft

Remove the duplicates from a linked-list.

Réponses aux questions d'entretien

Utilisateur anonyme

4 nov. 2010

I asked what was stored in the linked-list nodes, and the interviewer said "integers". I made a HashMap to store the values from the ListNodes. I iterated through the list, checking if they exist in the HashMap. If not, add the value of each node to the HashMap and move on. If so, remove the item from the LinkedList and move on. I'm not sure if this is the fastest way to do this.

Utilisateur anonyme

10 oct. 2011

Rather than "store the values from the list node", you should use the value as key for the hashing functions, and just mark its value to 1 if this is the first time you saw it, remove if its not the first time.