Google interview question

classic dynamic programming problem with a twist