Jane Street interview question

Optimal solution for flipping coin games with opponent