Helm.ai interview question

LeetCode question about 2D grid