Google Interview Question

A simple dynamic programming problem.