QuantitativePrimer icon indicating copy to clipboard operation
QuantitativePrimer copied to clipboard

Suggestion for the 'old friend' airplane question

Open jjpn97 opened this issue 6 years ago • 1 comments

Hi,

Just want to thank you for creating this doc, certainly helped for my interviews! Thought I should give back by suggesting a slightly easier solution for the airplane question (I think yours has a bit too much going on).

Define p_n = probability of last person in their seat if there are n people. Either the first person goes to their seat (with prob 1/n) and everything's fine, or the first person goes to any seat other than the last, in which case we return to the same problem with n-1 people.

So p_n = 1/n + (n-2)/n p_(n-1). Since p_2 = 1/2 it is simple to use induction to prove p_n = 1/2.

jjpn97 avatar Dec 06 '19 11:12 jjpn97

Hi! Thanks for this solution, I have seen a version of it before, and I tried giving this during one of my first interviews. However, the interviewer wanted me to work through all the tedious math I showed in the primer. It actually happened twice to me. That's why it has so much going on. I suggest giving the short, elegant answer that you mention, but be ready to go through the long one as well...

dwcoder avatar Dec 06 '19 18:12 dwcoder