Count Walking Routes Across an Office Floor With Blocked Desks
Last updated: November 29, 2026
Quick Overview
An office floor is a grid where 1 marks a blocked desk and 0 marks open floor. Count how many distinct right-or-down routes go from the top-left corner to the bottom-right corner without stepping on a blocked cell.
Meta
November 29, 20260
0
0 solved
An office floor is a grid where 1 marks a blocked desk and 0 marks open floor. Count how many distinct right-or-down routes go from the top-left corner to the bottom-right corner without stepping on a blocked cell.
A Meta phone screen staple framed around office space planning. The interviewer is looking for the counting recurrence, correct treatment of blocked start or end cells, and an O(columns) memory version.
What the Interviewer Expects
- Write the additive recurrence for path counts
- Zero out blocked cells correctly
- Handle a blocked start or target
- Use a single row of state
- Note that counts can be large and Python ints are unbounded
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- How would you return the count modulo 1e9+7 in a fixed-width language?
- What if the walker can also move diagonally down-right?
- How would you count routes that pass through a specific meeting room?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Input is a non-empty r x c grid of 0s and 1s. A route starts at (0, 0), ends at (r-1, c-1), moves only right or down, and never enters a 1. Return the number of such routes. If the start or end ...
High-Level Design
Let ways[i][j] be the number of valid routes to cell (i, j). A blocked cell has zero ways. Otherwise ways come from above plus from the left. The start has one way if it is open.
With a rolling r...