Apple interview question

Leetcode easy 2D array problem