Pregunta de entrevista de Matroid

Leetcode medium questions, one on 2D arrays