Pergunta de entrevista da empresa Google

Matrix based leetcode medium question.