As reported: Microsoft Senior Software Engineer (fullstack, Dec 2025), coding question 1: given a 2D matrix with blocked cells, decide whether you can reach
(m−1, n−1)from(0, 0)within timeT, moving in the four directions.
grid is an m × n matrix where 0 is an open cell and 1 is blocked. You start at (0, 0); each move goes to an adjacent open cell (up, down, left, right) and takes one unit of time. Return true if you can reach (m−1, n−1) within T time units.
Example 1
grid = [[0,0,0],
[1,1,0],
[0,0,0]], T = 4 -> true 4 moves: right, right, down, down
Example 2
same grid, T = 3 -> false
Example 3
grid = [[0,1],
[1,0]], T = 100 -> false the corner is walled off
Constraints: 1 ≤ m, n ≤ 200; 0 ≤ T ≤ 10^5.
Clarifications
- If the start or the target is blocked, the answer is
false. A1 × 1open grid needs0moves.
Code runner format: one JSON value per line: grid, T. Implement canReach(grid, T); the harness prints true or false.