google and microsoft interview questions and solutions (2)

来源:百度文库 编辑:神马文学网 时间:2024/04/27 07:00:59
1.Four people need to cross a rickety rope bridge to get back to theircamp at night. Unfortunately, they only have one flashlight and it onlyhas enough light left for seventeen minutes. The bridge is toodangerous to cross without a flashlight, and it’s only strong enough tosupport two people at any given time. Each of the campers walks at adifferent speed. One can cross the bridge in 1 minute, another in 2minutes, the third in 5 minutes, and the slow poke takes 10 minutes tocross. How do the campers make it across in 17 minutes?
Lets call the guys 1,2,5,10 for convenience based on time required togo. First, 1 and 2 go, 1 comes back , Total Time: 2+1 = 3 Second, 5& 10 go, 2 comes back (remember 2 is on other side from prev round), Total Time = 10+ 2+ 3(prev round) = 15. Third, 1 and 2 remain ,theygo, Total time = 2 + 15(from prev round) = 17.
2. If the probability of observing a car in 30 minutes on a highway is0.95, what is the probability of observing a car in 10 minutes(assuming constant default probability)?
solution 1:
You have to look at your probability of NOT seeing a car, which is .05in 30 minutes. In order to break this down into 10 minute chunks, youneed to figure out how you arrived at that probability, which would bex * x * x = .05, so x ^ 3 = .05.
I don‘t have a calculator, but the then you would have the third rootof .05. Then you would subtract that from 1 and arrive at your 10minute probability.
solution 2:
Let p is a probability to see a car in 10 minutes.
Then (1-p) is probability NOT to see a car in 10 minutes.
Then probability NOT to see a car in 30 minutes is (1-p)*(1-p)*(1-p).
(1-p)^3 == 0.05
So p = 1-0.05^(1/3)~ 0.63
3.In a country in which people only want boys, every family continuesto have children until they have a boy. if they have a girl, they haveanother child. if they have a boy, they stop. what is the proportion ofboys to girls in the country?
4.
You have an empty room, and a group of people waiting outside the room.At each step, you may either get one person into the room, or get oneout. Can you make subsequent steps, so that every possible combinationof people is achieved exactly once?