|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册
x
前段时间看到了一道传说中的Google面试题,把玩了一个星期,感觉很有意思。刚才在论坛里搜了下,发现大家没讨论过这个题目,就贴出来娱乐娱乐。
英文原题:
You are given 2 eggs.
You have access to a 100-storey building.
Eggs can be very hard or very fragile means it may break if dropped from the first floor or may not even break if dropped from 100th floor.Both eggs are identical.
You need to figure out the highest floor of a 100-storey building an egg can be dropped without breaking.
Now the question is how many drops you need to make. You are allowed to break 2 eggs in the process
无责任翻译:
给你两鸡蛋,你面前有一座一百层的楼。假设鸡蛋可以很脆弱,从一楼扔下去都能碎;也可以是超人鸡蛋,从100层扔下去也不碎。再假设两个鸡蛋是一摸一样的。现在问从100层建筑范围内丢这两个鸡蛋,需要丢几次能找出这两个鸡蛋最高从哪一层丢下去不会碎。你可以在尝试的过程中把两个鸡蛋都打碎。
我们学校一个数学老师不到一分钟算出了答案,本人由于智商问题纠结了一个星期,写了几个Python小脚本才研究通,有兴趣的同学回复了看答案吧。 |
|