NewsCred Interview Question

DP problem - hard