Pergunta de entrevista da empresa Capital One

One matrix question from leetcode