Count Robot Routes Across a Warehouse Floor With Blocked Cells
Last updated: November 29, 2026
Quick Overview
A warehouse drive unit starts at the top-left cell of a grid and must reach the bottom-right moving only right or down; some cells are blocked by pods. Return the number of distinct routes.
Amazon
November 29, 20260
0
0 solved
A warehouse drive unit starts at the top-left cell of a grid and must reach the bottom-right moving only right or down; some cells are blocked by pods. Return the number of distinct routes.
Amazon Robotics drive units navigate grid floors, which makes this classic grid DP a natural online assessment item. The interviewer checks base cases with obstacles in the first row or column and a 1D rolling array.
What the Interviewer Expects
- Define ways[r][c] as routes reaching cell (r, c)
- Recurrence from top and left neighbors
- Zero out blocked cells
- Compress to one row
- Handle a blocked start or end
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
- What if the robot can also move diagonally?
- Return the count modulo 1e9+7 for a 1000x1000 grid.
- What if each cell has a cost and you want the cheapest route instead?
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: grid of 0 (open) and 1 (blocked). Moves are right or down only. Output: number of routes from (0,0) to the bottom-right cell; 0 if either end is blocked....
High-Level Design
Every route into (r, c) arrives from (r-1, c) or (r, c-1), and these route sets are disjoint, so ways[r][c] = ways[r-1][c] + ways[r][c-1], or 0 if blocked.
A single row array suffices: before updat...