**Modified Birthday Problem:** a bunch of people line up, and the winner is the first person who shares their birthday with someone lined up ahead of them. What position in the line is optimal?


**Three (similar) approaches:** Recall the well known [Birthday Problem](https://en.wikipedia.org/wiki/Birthday_problem), and let $b(n)$ denote the likelihood that there is a shared birthday in a collection of $n$ people. Suppose you are the $(n+1)$st person in line, and you want to be the first person to share your birthday with someone ahead of you. 'None of the people ahead of you sharing a birthday' happens with probability $1 - b(n)$, and 'you sharing a birthday with one of them' happens with probability $n/365$. Therefore, we wish to maximize: $(1-b(n))(n/365)$. A computer search (e.g. in WolframAlpha) can find $n$ is about $19$, and so you want position $20$.


Alternatively, we can [approximate](https://en.wikipedia.org/wiki/Birthday_problem#Approximations) $1-b(n)$ with $e^{-n(n-1)/730}$ pretty well. Now consider setting $\frac{d}{dx} e^{-x(x-1)/730} (x/365) = 0,$ which ends up requiring only that we solve a quadratic. In particular, we end up with the quadratic $x^2 - x/2 = 365.$ Then $x$ is a little over $19$, and again we guess the optimal position is at $20.$


Finally, we consider the ratio of probabilities of winning for consecutive people in line. Eliding over some details (e.g. showing initial ratio $> 1$, the ratios are decreasing) we can check to see when this ratio drops below $1.$ This will again culminate in solving a quadratic, namely, $x^2 - x = 365.$ Since $x$ is about $19$, we have (for the third time) found the optimal position to be at $20.$


**Question 0:** Why do the quadratics arrived at in our second and third approach differ? (I suspect this is just an artifact of the rough estimation used in the second approach, although I could not explain the reasoning behind this difference in any greater detail.)


**Question 1:** Since our third method indicates that solving for $x$ in $x(x-1) = 365$ ultimately leads to the solution, I am wondering: is there a way to have seen "at a glance" the importance of this quadratic? My intuition tells me that there is a much more straightforward way of thinking about this problem, but I am not sure what it would be.



Solving a modified birthday problem at a glance
The approaches in the OP already seem quite straightforward to me, and as is clear from the answer by Arthur B, doing the calculation exactly is not too complicated. 


Anyway, here is my suggestion (after a bit of scribbling) for how one might have seen the solution at a glance.


All we have to do is compare the winning chances of person $k$ and person $k+1$ (provided we do it for general $k$). Edit: this is because the winning chances are first increasing and then decreasing, which of course isn't clear a priori, so perhaps the previous sentence should have started "As it turns out...".


We imagine two persons A and B who are to occupy places $k$ and $k+1$. We only have to compare the scenarios where the one who goes first wins, to the scenarios where the one who goes second wins (otherwise the order of A and B doesn't matter).


Those scenarios first of all require that persons $1,\dots, k-1$ have different birthdays.


Under that assumption, the cases where the person to go first wins are when both A and B have a birthday which is already represented among the first $k-1$ people. Counting combinatorially rather than probabilistically, there are $(k-1)^2$ ways of choosing the birthdays of A and B with that constraint.


The cases where the person to go second wins are when A and B have the same birthday, and that birthday is not shared with any of the first $k-1$ people. There are $n-(k-1)$ such ways of choosing the birthdays of A and B. 


Therefore we end up comparing $(k-1)^2$ to $n-(k-1)$, or equivalently comparing $k(k-1)$ to $n$.


After having written it down, I get the feeling that this argument is more convoluted than the straightforward calculation by Arthur B, but here it is, for what it's worth.


