Microsoft Interview Question for Software Engineer / Developers


Country: India
Interview Type: Phone Interview




Comment hidden because of low score. Click to expand.
1
of 1 vote

Use hash table with key "word" and "count" as value.

- Anonymous September 22, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

I also think its the best way and probably the simplest logic too.

- sati September 22, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

I think hash tables is not good in this situation. The restriction over the load factor cannot be reserved here, resulting in a big list of words on each key.

- WDk September 27, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Constructing a trie will help.

- voora.ravishankar September 20, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Please will you provide a detail steps
Thanks in advance :)

- bhaskar.parimala September 20, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Following link gives you better understanding.
en.wikipedia.org/wiki/Trie
In leaf node you can put count(occurrences of the word).
So once you construct a trie, you can easily tell number of occurrences of word(Time Complexity for searching = size of word)

- voora.ravishankar September 20, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

What can be more optimal than iterating over the document character only once?

I think the solution is to iterate over each word from the beginning, while adding each word to the Trie. When we try to add a word that already in, then we update the $->counter of that word to be $->counter=$->counter+1.

Note: $ is the closing character of each word on the Trie. To $ we add a field called counter that count each occurrence of that word.

As voora suggested, reading about Trie might help you understand the solution.

- WDk September 27, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Write a map reduce job for word count.
Mapper: tokenize a line and emit (word, 1)
Reducer: add all values for the key and save the sum corresponding to the word
For performance use combiner which is same as reducer.

- Anonymous September 20, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

This is not an optimal solution.
because determining the Map's Bucket size is an overhead.
the same Map solution i discussed with the interviewer he is not satisfied.
asked me to come up with better one :(

- bhaskar.parimala September 20, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

This is not an optimal solution.
because determining the Map's Bucket size is an overhead.
the same Map solution i discussed with the interviewer he is not satisfied.
asked me to come up with better one :(

- bhaskar.parimala September 20, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

@ bhasker this is not the regular MAP you are thinking off.. he is talking about MAP_Reduce merge programming paradigm ... google for it.

- M September 20, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Install hadoop and ask it!
[I guess they dont use map reduce at microsoft, they are still catching up with google]

- GodKillsKittens September 21, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

I like your comment :-)

- P December 08, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Trie/Prefix tree

- choupsey October 17, 2011 | 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