Domanda di colloquio di Google

it was Dynamic Programming question