Medius interview question

Leetcode problem involving matrix algorithms