Pregunta de entrevista de Google

Matrix based leetcode medium question.