Question d'entretien d'embauche Northrop Grumman: Describe an algorithm that wi... |

Question d'entretien d'embauche

Entretien de Software Engineer(Internship) Oklahoma City, OK (États-Unis)

Describe an algorithm that will take in a large input of

  English words that may contain duplicate. Then return only unique words from the input.

Réponse de l'entretien

7 réponses


Put the items in a hash map, then return the hash map. Since hashmap eliminates duplicates.

Candidat à l'entretien, le 3 déc. 2018

I was interviewed today and they asked this question, so you can probably expect it!

My solution was to use a linked list to store the words, and with every new word you would conduct a linear search and discard it if it was a duplicate. Horribly inefficient and I am pinching myself for not remember my hashtables :(

John Doe, le 20 févr. 2019

Use a set since they don't allow for duplicates and have arbitrary order. Implement the set using a hashtable for constant time checks to see if the word is already in it.

Utilisateur anonyme, le 7 avr. 2019

Hey guys I used rooftop slushie to get an answer for this interview at Northrop Grumman. You should give it a try.

Utilisateur anonyme, le 11 juil. 2019

Sort the array, and then loop through each loop. This should result in a O(n) + O(n) vs O(n^2)

Utilisateur anonyme, le 23 sept. 2019

In python you could do this with

Def interview(x):
    #[str] -> [str]
    Return set(x)

Could also use collections.Counter
Then loop through key value pairs

Utilisateur anonyme, le 24 sept. 2019

C#, put them into a SortedSet. It will only show the distinct ones.

Trent Nguyen, le 6 nov. 2019

Ajouter des réponses ou des commentaires

Pour commenter ceci, se connecter ou s'inscrire