面试题来自Jane Street Capital,在香港有分公司,总部在NYC,很牛逼的公司。下面分享两道经典面试题:
1. You have 3000 apples at Edingburgh want to transfer as many apples as you can to London. You have a truck, the maximum capacity of which is 1000 apples. London is 1000 miles away from Cambridge and when the truck is carrying apples, for every mile it drives, it will drop one apple. What is the maximum number of apples you can deliver to London?
Answer:
1) In three separate trips, we will transfer the 3000 apples to our first stopping point. At the first stopping point, we want to have as close to 2000 apples as possible. This way, when we start moving again, we have as close to 1000 apples as possible in our truck.
This leads us to solving: 3000-3*x=2000 => x~333.33 miles (round up to 334), where x is the distance in miles we travel to the first stopping point. Note that we multiply 'x' times 3 since we are taking the apples in three separate runs. After truckin' the 3000 apples, in three separate runs, 334 miles, we have 3000-3*334=1998 apples left and 666 miles left to go.
2) At the second stopping point, we want to have as close to 1000 apples as possible. This way, when we start moving again, we have as close to 1000 apples as possible in our truck. This leads us to solving: 1998-2*y=2000 => y=499, where y is the first stopping point. Note that we multiply 'x' times2 since we are taking the apples in two separate runs. Now, we have 1998-2*499=1000 apples left and 167 miles left to go.
3) We then load up the truck with a 1000 apples and travel 167 miles. At the end, we have 1000-167=833 apples
2. 抛一个10个面的dice,数字分别为1-10。记下每次抛后的面值并做累加,一旦总和超过100则停止。请问最终最有可能得到的总和值为多少?
Answer: 我用Monte-Carlo仿真计算结果为104,但不知理论解法如何。有高人指点否?