Microsoft Interview Question

Simple 1D Dynamic Programming Question