X interview question

Was basically a 2d matrix question, more or less leetcode medium