Interview Question for Front-end Software Engineers


Team: Web Developer
Country: United States
Interview Type: Phone Interview




Comment hidden because of low score. Click to expand.
5
of 7 vote

1) For each word calculate key where key= word sorted in alphabetical order. Hence if the word is APPLE , the key becomes AELPP.
2) Store these words in a hash with key as above and value as boolean true.
3) for any inpur word apply the above hash function and get key. Then search in the hash table for the key.

- Yoda July 17, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

You can just use HashSet. No need to store the boolean.

- Anonymous July 18, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

while checking for anagram do we need to consider for " - " and " ' " ??

- cobra July 18, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

As @singhsourabh90 mentioned : trie structure is the optimal one! Though little bit preprocessing is required!

Searching the word will take o(length_of_word_to_be_searched)

- Psycho July 24, 2012 | Flag
Comment hidden because of low score. Click to expand.
3
of 3 vote

sort the 100 word's :
create trie of sorted words :

now create a function which :
1) take's input word sort's it.[ make a copy of word if changing original is not allowed .]
2) search word in trie
3) return's true or false accordingly .

- singhsourabh90 July 18, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

I am not sure how you would implement trie on this case without sorting each word first alphabetically, like bag as abg and ball as abll.. in this case you would have single trie. now you would sort the input alphabetically and search it in the trie as the expense of space though.

- ethioer July 23, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

sry, forgot to mention sort 100 word's. (included). sorting word list and sorting each word itself also .:)

- singhsourabh90 July 23, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

One can also go for TRIE. Store all the 100 words in TRIE in sorted form.
As a new word comes, search for its sorted sequence in the TRIE.
The time complexity would be O(length of the word to be searched).
However, it is space consuming.Ternary search trees can be used to reduce the space..

- Aashish July 24, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

At first, needs to know if it is unicode or Ascii, and check if it is upper case or lower case like if "C" and "c" is the same. At last you can use hash table to check if it is an anagram or not.

- dolremi July 17, 2012 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More