Domanda di colloquio di Google

As much as I recall it is a Dynamic Programming question.