Amazon Interview Question for Software Engineer / Developers


Country: India
Interview Type: In-Person




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

If original bigger matrix is M, smaller matrix to be found is m.

Since file is too large to be in memory, it will have to be broken down and brought in chunk by chunk

I think there are two parts to this question:
1. If a piece of file/matrix M is present in the memory, how would we find the pattern m in it, most efficiently
2. If the patter m is present in two chunks i.e. if a chunk is present in the memory, m could be partly present in that and partly in the incoming chunk.

- puneet.sohi April 21, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Keeping that in mind, we could a line by line comparison between matrix m and the file present in the memory(this can be made more efficient, by hashing for instance)
If we overrun the the chunk present in the mem, there can be two cases.

1. If we had a partial match i.e. part of m was present in the current chunk. In that case, bring in the next chunk, and continue the search
2. If no match, bring in the next chunk, and start afresh.

- puneet.sohi April 21, 2014 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Maybe a stupid question, but how large is the file? Too large to be entirely on memory? And what is the exact format of the file? Is it like n lines each separated by a newline character where each line is n characters of '+' or '.'?

- lemonedo April 20, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Yes file is large to be entirely on memory.
The file line consists of plus and dots.

- hulk April 20, 2014 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

suffix tree can help in finding the pattern and it can be modified to return count..

- Anonymous April 21, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

can you share more on how this can be solved by suffix tree?

- linusyang2016 May 13, 2014 | Flag


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