Forward Interview Question

LC-like 2D array traversal/manipulation question