Amazon Interview Question for Software Engineer / Developers






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

let the point are (x1,y1) and (x2,y2)
diagonal moves m=MOD(x1-x2)
horizontal move n = MOD(MOD(y1-y2)-m)
total number of shortest path = !(m+n)/!m!n

- Anonymous July 21, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
1
of 1 vote

I think it should be MAX(|A-C|, |B-D|) - MIN(|A-C|,|B-D|) + 1.1* MIN(|A-C|, |B-D|) = MAX(|A-C|, |B-D|) + 0.1 * MIN(|A-C|, |B-D|) , right?

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

correct

Tried with some example like 4 X 6 and distance between (2,0) and (0,5)

- abrahm July 21, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

@jproboy: the formula seems to work but can you explain how you reached there??

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

Let's consider the distance from (0,0) ->vertical-> (0,1) , (0,0) ->horizontal-> (1,0), (0,0)->diagonal->(1,1) as one step. Then the cost of moving along diagonal is 1.1*step, moving thought vertical and horizontal will cost 1*step+1*step = 2*step > 1.1*step. So we always choose diagonal as long as possible. the cost for longest diagonal will be 1.1* MIN(|A-C|, |B-D|). and left MAX(|A-C|, |B-D|) - MIN(|A-C|,|B-D|) step for horizontal or vertical which cost 1 for each step.

- jproboy July 22, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 2 vote

You missed the point. The answer is to move diagonally until you are aligned vertical or horizon with the other point. (a,b) --> (c,d) = 1.1 * Min( |a-c|, |b-d| ) + 1 * Max( |a-c|, |b-d| ). The number of shortest paths is Max( |a-c|, |b-d| ) - Min( |a-c|, |b-d| ) + 1.

It's a logical analysis problem.

- Dr. GUI July 20, 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