noon Interview Question

a DP problem to solve