Amazon Interview Question for Software Engineer / Developers






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

Solution for this case is very simple. Just ask the first person to add a random value to his salary and pass it on to the next person. The other person will add his salary value to it and pass it on to the other. Finally, the total sum is passed on to first person. He subtracts his value to get the total sum. Finding the average is then trivial.

- Anonymous February 27, 2008 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

if the conversation is aloud, then c can know the salary of b.
zdmytriv's solution below sounds more robust.

- akshay kumar June 03, 2008 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

a tells a1 to b
a tells a2 to c

If conversation is aloud b can listen wat was told to him and c then add.

- jack July 02, 2008 | Flag
Comment hidden because of low score. Click to expand.
2
of 2 vote

a, b, c - salaries

For each cases divide salaries into random pieces
a = a1 + a2
b = b1 + b2
c = c1 + c2

first A will tell a1 to B , now b will add b1 to a1 and send [a1+b1] to C
Now C will add c1 to this . Now C have s1=[a1+b1+c1].

Now C will send c2 to B and B will add b2 to this and send [c2+b2] to A, now A will add a2 tho this. So A have s2=[a2+b2+c2]

Now Finally set average by [s1+s2]/3

- Ravi July 23, 2008 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

This can also be solved as follows:
Here x, y and z are random numbers.
A gives a+x to B
B gives a+x+b+y to C
C gives a+x+b+y+c+z to A
Now, A will subtract x from the sum and give it to B. Similarly B will subtract y from the sum and give it to C, C can then subtract z and get the average.

- Akhil September 16, 2008 | Flag
Comment hidden because of low score. Click to expand.
1
of 1 vote

This i suppose is the best sol.. nobody gets to know others salary

- Anonymous December 15, 2008 | Flag
Comment hidden because of low score. Click to expand.
1
of 1 vote

a, b, c - salaries

For each cases divide salaries into random pieces
a = a1 + a2
b = b1 + b2
c = c1 + c2

a and c tells a1 and c1 to b: a1 + b1 + c1 = s1
a and b tells a2 and b2 to c: a2 + b2 + c2 = s2
(s1 + s2)/3 - average

- zdmytriv March 06, 2008 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

By this way A has disclose his whole salary , so it cannot be right answer

- Ravi July 23, 2008 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Let A divide His/her salary. Say a1, a1.
A will tell a1 to B and then B can add his/her salary to a1.
s1 = a1 + B.
Now B will tell s1 to C and C can add his/her salary to s1.
s2 = s1 + C.

Now will tell S2 to A and can add a2 to S2.
s = s2 + a2.
now we have the total. divide s by 3.

- Dees February 13, 2009 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Good solution!

- vodangkhoa March 05, 2008 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

May be we can do the same by using friendly function in C++

- kushal July 01, 2008 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

The random number answer sounds great.

Let A, B and C disclose their salaries to D, and D do the calculation and then tell them the average.

- Anonymous September 17, 2008 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

lolll ... or they should just stop being such pompous asses and discuss the damn thing in open already than to make stupid questions for excruciating interviews

- Anonymous November 11, 2008 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Each salary divided by 3.
A gives a1 to B, a2 to C and left a3
B gives b1 to A, b2 to C and left b3
C gives c1 to A, c2 to B and left c3
A+B+C - their sum
whole salaries have not been disclosed

- Victor September 25, 2008 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

:-)

there is no mention that a forth person's help should not be used.

- Sunny October 17, 2008 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

A picks 2 random numbers, a1 and a2, such that average(a1, a2)=salary(A). B and C do the same.

A gives a1 to B, who calculates B'=average(a1, b2)
B gives b1 to C, who calculates C'=average(b1, c2)
C gives c1 to A, who calculates A'=average(c1, a2)

Now the A', B' and C' can be revealed and final average calculated.

- JD June 11, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

awesome

- rblhli August 24, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

salary A + random A ( A gives this to B )

salary A + random A
salary B + random B ( B gives this to C )

salary A + random A
salary B + random B
salary C + random C ( C gives this to A )

salary A+
salary B + random B
salary C + random C ( A removes random A & gives the total to B )

salary A+
salary B+
salary C+ random C ( B removes random B & gives the total to C )

salary A+
salary B+
salary C+ ( C removes random C & gives the total to A )

now A has the total of their salaries from which Average can be calculated..

- MQA August 31, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

c fixes 2 arbitary nos x and y....he tell x to a and y to b
a adds x to his salary and passes the sum to b..
b adds y to his salary and adds a's pseudo salary to it and passes it to c..
c subtracts x+y from the sum and adds his salary to it and divides it by 3...

now the avg is declared!!!!

- sg December 13, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Adding to above comments.

A->6$ , B->5$ c->10$ ( c fixed 2$ fake salary for a and 3$ for b)

1.A- 6+2...passes to b..
2.B- 5+3+(A pseudo salary which is 8?)=16..pass to c.
3.c- 16-(2+3)=11+(his real salary)/3

- kapoor.utd March 29, 2010 | 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