In an urn, there are m red balls and n green balls.
Every minute, you toss a coin and decide which color to draw, then remove one ball of that color from the urn. (e.g. remove one green ball if it is a tail)
What is the expected number of balls left in the jar after you have drawn all red or green balls?
Note that 0 <= m+n <= 10^5 And the solution should be implemented in a way that it return results within 5 second using 1 CPU and 1GB ram.
p.s. this is an interview question I found online (from some interview question banks), tried to attack this problem using binomial / negative-binomial distribution but no luck so far