Pregunta de entrevista de Capital One

One matrix question from leetcode