Amazon Interview Question for Applications Developers


Country: United States




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

I cant understand the question. Anyone pls explain.

- pradeep December 12, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

me too :(

- kary December 16, 2012 | Flag
Comment hidden because of low score. Click to expand.
1
of 1 vote

There must be some catch in this question. Is there any time complexity expectation? The simplest would be of O(m*n) complexity.
Algorithm would be:
- Find first row from _top_ which has at least one column in that row as '1'
- Find first row from _bottom_ which has at least one column in that row as '1'

The difference of the above row numbers + 1 is height of the character.

Thanks,
Laxmi

- Laxmi Narsimha Rao Oruganti December 11, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

I think this can be solved in n*log(m)
- From top search for 1 in each row till first occurance using binary search
- Once you find that, perform same from bottom
Difference between row nums + 1 is your required height

- Phani December 11, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

@Phani we cannot use binary search as it is not sorted

- rahul December 14, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

I am assuming that the question can be interpreted as a MXN grid with 1 in each cell where the character's part lies, 0 otherwise. Assuming that the character dots will be connected, it means all the cells numbered 1 will be connected. We need to figure out the maximum extent of the connected cells.
Approach
Travel in the diagonal direction, till you hit a cell with value 1. If you do not hit any cell with 1, then either half of the matrix does not contain any character and hence the cells to be tested will be reduced(not necessarily halved).

Once you get one cell having value 1, you can start that as a seed and do a traversal of the connected cells keeping an eye on the yMin and yMax of the visited cells.

- SR December 11, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

thinking about you approach for all characters...

need to rethink the later part of algo for disconnected characters like "i", "j", etc.,

- siva December 11, 2012 | Flag
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
0
of 0 votes

Is the binary search approach correct, as per my understanding the data is not sorted.

- SR December 11, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

I am sorry, but can you explain how would you use binary search here? Let us take an example of letter: J. In this case, middle char would not be '1'. How do you select which half to probe further? Is it left half or right half?

- Laxmi Narsimha Rao Oruganti December 11, 2012 | 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