Pergunta de entrevista da empresa CoinSwitch

Matrix-based DSA question, with follow-ups.