Amazon Interview Question for Software Engineer / Developers






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

It is

1 - 1/2 * 1/2 * 1/2 * 1/2 =>  15/16

- AK May 20, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

aggree

- pansophism May 20, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

aaply
Multiplication Rule 1: When two events, A and B, are independent, the probability of both occurring is:
P(A and B) = P(A) ยท P(B)

- tima May 20, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

So isn't the solution wrong?

- How can the total probability be > 1 ? May 21, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

This solution is correct, it is the combined probability of all possible events minus the probability that all four people will NOT open the door (1/2)^4. Another way to look at this problem would be to take the sum of the probabilities of all possible ways that the door will be opened:

P[person a opens the door] = 0.5

+ P[2 people open door] = P[person a] * P[person b] = 0.25

+ P[3 people open door] = P[person a] * P[person b] * P[person c] = 0.125

+ P[all 4 open door] = P[person a] * P[person b] * P[person c] * P[person d] = 0.0625

= 0.5 + 0.25 + 0.125 + 0.0625 = 0.9375 that the door will be opened, or 15/16.

- Anonymous May 08, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

I think we need to clarify the question first.
The question said "enter the room when ONE person open the door."
Should we enter the room when >= 2 people open the door??

- wfchiang May 21, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

15/16

- Anonymous May 22, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

yup, that's right

- Anonymous July 26, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

1 - 1/2 * 1/2 * 1/2 * 1/2 => 15/16

- bharath.paturi May 23, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

there are 4 persons in the room
the one who is waiting outside can enter only when 1 of the 4 opens the door(4 out of 16 possibilities)
the probability for opening the door by any one of 4 is 1/2
so (4/16)*(1/2)=1/8 is my answer.

- Master May 24, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

the probability of somebody opening the door is 1/2

it means we are not aware of the probabilities of other three people. so we can't assume anything.

Now the door can be opened only when this 'somebody' opens the door.

The probability of selecting this 'somebody' out of four people is 1/4

And hence the probability of the door being opened = P ( selecting somebody) * P( somebody opening the door)
= 1/4 * 1/2 = 1/8

- kaushik May 26, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

its like case1- 1st person open the door rest dont open(1/2 * 1/2 * 1/2 * 1/2)
case2- 2nd opens the door and rest dont open(1/2 * 1/2 *1/2 * 1/2)
case3-
case 4-
adding all=1/4 * 1/16 =1/4.......isnt that fine....

- nit_allahabad June 16, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

two people open the door at same time = 1/2 *1/2 = 1/4

three people open the door at same time = 1/2 * 1 /2 * 1/2 = 1 /8

four people open the door at same time = 1/2 * 1/2 * 1/2 * 1/2 = 1/ 16

more than one people open the door at same time = 1/4 + 1/8 + 1/ 16 = 7/16
only one person open the door = 1 - 7 / 16 = 9 / 16
????

- guest June 16, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

I agree with this answer, even I got the same o/p with another approach
Four of them opening the door : 1/2
One of them opening the door : 1/2*1/2*1/2*1/2=1/16
Opening the door: one of them or four of them = 1/2+1/16=9/16

- Sivaji June 30, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

That's wrong.
only one person open the door = 1 - 7 / 16 - Prob(nobody opens the door) = 1 - 7 / 16 - 1 / 16 = 8 / 16 = 1 / 2

The same answer can be obtain in the following way:
only one person open the door = Pob(first_person_is_selected) * Prob(first_person_opens_the_door) + .. + Pob(fourth_person_is_selected) * Prob(fourth_person_opens_the_door) = 1/4 * 1/2 + .. +1/4 *1/2 = 1/2

- Aleksey.M January 21, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

1-1/2*1/2*1/2*1/2 = 15/16

- krishna June 17, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

simple:
a|b only excludes the possibility ^a&^b so p(a|b) + p(^a^b)=1 =>p(a|b)=1-p(^a^b)
also p(ab)=p(a)*p(b) => p(a|b) = 1-p(^a&^b) = 1-p(^a)*p(^b)
so probability p(a|b|c|d) = 1-p(^a^b^c^d)=1-(.5*.5*.5*.5) = 93.75/100

you can derive probability equations using logical deduction + simple mathematics.

- Rob Scott June 18, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Lets try to understand it in a different way. By definition, the probability that a ceratin event will happen is: number of favourable outcomes divided by total number of outcomes.

so in this case, number of favourable outcomes (i.e. the door will be opened) = number of ways so that atleast of one the person opens the the door.

Total number of outcomes = 2 * 2 * 2 * 2 = 16, because each person can indepenedently have two different options: either to open the door, or not to. So, total outcomes is 16.

out of these 16 outcomes, only one outcome is unfavourable i.e. all four DO NOT open the door. rest in all other 15 cases, atleast one of the persons will definitely open the door.

Therefore, P(i can enter) = 15/16 = 93.75 %

- Harleen June 28, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

The answer is 15/16.

1. probability cases:
(atleast one person opens) + 2 people opens the door + 3 people opens the door + all 4 people open the door

2. 1 can be simply calculated using 1 - (no one opens the door) which comes up to 1 - 1/16 = 15/16

- SS July 05, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

As there are no condition except any one can open the door.. the probability of selecting anyone from four is 1 and opening door is 1/2. therefore probability is 1*1/2=1/2. think practically two or three members opening door is silly..

- dev September 22, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

{p1,p2,p3,p4 } so there are 16 possibilities all of them not opening the door is the only negative case hence the probability is 15/16

- Arun prasath Nagarajan October 02, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

i think 7/8 is the answer

- abc August 20, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

I opened this thread because lot of people confused in this puzzle ..acc to me i think its clear that question says somebody not particular person ..isn't it so if any1 will open the door then one can get inside ..isn't it...& thats the 1/2 ..i don't why confusion ??? let me know if i missed sunmthing

- WgpShashank May 20, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

I agree with this. As there are no condition like that... any body open the Door and every probability is 1/2 so total probability of opening the door is adding 1/4*1/2 4 times which comes as 1/2. there is no condition between any person.

@WgpShashank--> as you calculated the probability of not opening the Door is 1/2*1/2*1/2*1/2 and subtracting it from 1. Similarly I can say probability of opening the door is 1/2*1/2*1/2*1/2 which comes as 1/16 which is not same as your answer.

- Sanjay May 20, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

I Mean to say to AK.

- Sanjay May 20, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

@Sanjay:
How can you say that probability of opening the door is 1/16. You calculated when every body inside the room open the door at the same time.
Probability of getting in is that at least one person opens the door which is same as (1-p(no body opens the door)). So in my opinion AK is correct.

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

@Tulley Please read the question carefully. the statement is somebody open the door is 1/2 mean the probability of opening the door is 1/2. No where is given the probability of opening the door by each person is 1/2.

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

@Sanjay
Correct, I misinterpreted the question. The answer should be 1/2.

- Tulley May 22, 2011 | Flag
Comment hidden because of low score. Click to expand.
-1
of 1 vote

for one person, the possible action is taking no action, opening 1/2 and opening the door, every action has 1/3 possibility. The only way you can not enter is 3 person no action, the forth one takes no action or opens 1/2, which the possibility is (1/3) * (1/3) * (1/3) * (2/3) = 2/81.

So my answer is 1- 2/81 = 79/81.

- wxhwxhwxh May 20, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

not opening the door and taking no action are same..

- Anonymous July 26, 2012 | Flag
Comment hidden because of low score. Click to expand.
-1
of 1 vote

if atleast one person opens the door probability = 15/16
if only one person opens the door probability = 1/4

- MSD May 27, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

As i think this question is wrong or missing something. There are four person in a room and probability of opening the door by each person is 1/2 so total probability is 2 which is not possible so some more information is required

- raj June 05, 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