Capital One interview question

One matrix question from leetcode