Amazon.com

  www.amazon.com
  www.amazon.com

Interview Question

Software Engineer Intern Interview(Student Candidate)

Given a keyword (ex: "abc") and a list of words (ex

  "cab", "ab"), write a function that will return all words in the list that are the same/anagrams of the keyword. In this case, "cab" would be the only word returned. Later changes to the function were added: numbers and symbols might be included in the words but were to be ignored ("ca2b" still matched "abc"), make the function not case sensitive ("A" == "a"), etc...
Tags:
technical
Answer

Interview Answer

1 Answer

0

First, I hashed the keyword, making the letter the key and the number of times it appears a value. I did the same thing to the words in the list, skipping words that weren't the same length as the keyword (removed once he added the condition to ignore numbers and symbols). There were also other optimizations added.
Also, if you use a hashmap or any data structure, be prepared to answer why you used it. (Runtime, etc)

Interview Candidate on Mar 2, 2014

Add Answers or Comments

To comment on this, Sign In or Sign Up.