Matroid interview question

Leetcode medium questions, one on 2D arrays