Google interview question

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