Google interview question

A DP problem about combinatorics