Anonymous interview question

dynamic programming problem with a twist