Domanda di colloquio di Google

Two dynamic programming questions. One is easy, the other is hard.