StackAdapt Interview Question

Galton Watson Branching Process and DP Programming question