Microsoft Interview Question for SDE-2s


Country: United States
Interview Type: In-Person




Comment hidden because of low score. Click to expand.
2
of 4 vote

This is as simple as building a TRIE out of incoming words and storing the start index at the leafs.

- koustav.adorable September 01, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
1
of 1 vote

Because q/s is about efficient DS. Trie is most efficient in handling dictionary than a hash table

- sayantanc85 September 12, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

@koustav.adorable why not maintain a hash table with value set to list of indexes? scan will take O(N), search is O(1)

- PenChief September 10, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

it should use suffix array or suffix tree to solve the problem.

- tiandiao123 September 13, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

This problem is the same as string match. Can be solved using kmp algorithm. Complexity will be O(m+n) where m is the length of text and n is the length of given word. space complexity will be only O(n) for the pattern/word vector.

- Anonymous December 29, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Isn't a TRIE O(n) time complexity, just like, for example, a rolling hash? I think these solutions are pretty similar, but the rolling hash should handle space better.

- Luca October 08, 2020 | 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