Pregunta de entrevista de Forward

LC-like 2D array traversal/manipulation question