Concentric AI Interview Question

DP problem for the DSA round