Microsoft Interview Question

related to dynamic programming question