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
Coding & Algorithms
Software Engineer
Meta
November 29, 2026
Software Engineer
Phone Screen
Coding & Algorithms
Easy

0

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
Grid dynamic programming
Combinatorics
Obstacles
Rolling array
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. 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 Problems
Sample 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...


Submit Your Answer
Markdown supported