Google interview question

Matrix and algorithms manipulation question