StackAdapt interview question

Galton Watson Branching Process and DP Programming question