## Amazon Interview Question for Software Engineer / Developers

• 0

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

1) Divide 9 marbles into group of 3, and then select any two group and check their weight. If either of is heavier, then select that group or select third group. Now select any two marbles out of this group of three and check their weight. By this procedure you need to compare just twice.

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

To find two nos in array whose sum is equal to given no:
1) If array is sorted the your method can give result in O(n) else it will require O(nlgn) + O(n)
2) If memory is not the constraint then add each element of array in hasttable in O(n). In other O(n) find the two nos. Total : O(n) + O(n)

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

1 evaluate(ExpressionTree t){
if(t is a leaf)
return value of t's operand ;
4 else{
5 operator = t.element ;
6 operand1 = evaluate(t.left) ;
7 operand2 = evaluate(t.right) ;
8 return(applyOperator(operand1, operator, operand2) ;
9 }
}

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

For the marbles problem, how are you able to say it is log n. Since you are diving it into group of three each time

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

Two years ago, I passed two phone interviews and went to Seattle WA for the interview. I was asked about the same elevator question in my second phone interview. It is amazing that they keep asking the same questions again and again over several years.

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

BTW the 9 marbles question is a variation of the original question which had only 8 marbles. 9 marbles can be solved by using the scale only 2 times.

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

The marbles problem has the answer log n(to base 3) only if, its given that the odd marble is either lighter or heavier.

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

Mindy, so finally you answered the "elevator question" and got hired by Amazon? You rock Mindy!
So give tips to your other friends out here who are waiting to be hired by Amazon. :-)

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.

### 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.