Matroid Interview Question

Leetcode medium questions, one on 2D arrays