Airplane Seat Assignment Probability
给n个人, 坐n个座位, 第一个人随机选, 问第n个人坐到自己座位的概率.
这题就多写几个例子就行了
class Solution {
public double nthPersonGetsNthSeat(int n) {
if(n == 1)
return 1d;
if(n == 2)
return 0.5;
return 0.5;
}
}
// f(n) = 1/n+ 1/n*f(n-1)