Google Interview Question

a very difficult dynamic programming problem