Domanda di colloquio di Mastercard

DP based problem(medium-hard) in first round.