Amazon Interview Question
SDE1sCountry: India
Interview Type: Written Test
Hi Guys, i am new and learning. but that above seems not correct.
we have 24 socks, 12 black and 12 white.
picking 1 sock out of 24 is: 1/24.
as we have 12 black socks, picking 1 black sock out of 24 is: 1/24 * 12 = 12/24 = 1/2
so picking of any single color, black or white is, 1/2 chance..
Now to pick the second black sock out of 23 socks (as we have already selected 1) is: 11/23 (as we have 11 black socks left in 23 socks)
So probability of picking 2 block sock is: (1/2) * (11/23) = 11/46
So picking any white or black pair out in dark is: 11/46,
Please correct if i am wrong
@lazylearner You are correct till "So probability of picking 2 block sock is: (1/2) * (11/23) = 11/46"
But your next statement is wrong.
Probability of picking 2 black socks = 11/46
On similar lines, probability of picking 2 white socks = 11/46
So, probability of picking either 2 black socks or 2 white socks = 11/46 + 11/46 = 11/23
P(both socks are white) = P(1st sock is white) * P(2nd sock is white) = 12/24 * 11/23 = 132/552
P(both socks are black) = P(1st sock is black) * P(2nd sock is black) = 12/24 * 11/23 = 132/552
P(both socks are the same) = P(both socks are white) + P(both socks are black) = 132/552 + 132/552 = 264/552 = 11/23
There are 6 pairs of white socks and 6 pairs of black socks which means that the total number of socks are 24, so the answer should be
2 * (12 * 11) / ( 24 * 23 ) = 11 / 23
Correct me If I am wrong.
The correct answer to the stated question is 50%. If you pick two socks at random, the two possible outcomes--match or non-match--have equal probability, so each outcome has a probability of 50%. The answer being given by everyone else is correct for a different question--what is the probability of a second draw being the same as the first draw conditional on what was selected on the first draw.
number of ways to pick any 2 socks from 24 socks = 24C2
- algos July 29, 2013number of ways to pick 2 BLACK socks from 12 BLACK socks = 12C2
probability of picking 2 BLACK socks = 12C2 / 24C2 = 66/276
probability of picking 2 WHITE socks = 12C2 / 24C2 = 66/276
probability of picking any 2 same color socks = 66/276 + 66/276 = 11/23