Pregunta de entrevista de CoinSwitch

Matrix-based DSA question, with follow-ups.