Pregunta de entrevista de Visa Inc.

2d matrix question from leetcode