Amazon Interview Question

DP problem [Medium] and Class Design [Medium]