Pregunta de entrevista de Google

Matrix and algorithms manipulation question