Mark Storage Zones Fully Enclosed by Shelving on a Floor Plan
Last updated: November 29, 2026
Quick Overview
A warehouse floor plan grid uses 'S' for shelving and 'O' for open floor. Open cells that cannot reach the outer edge of the floor through other open cells (4-directionally) are enclosed dead zones; convert every enclosed 'O' to 'S' in place.
Amazon
November 29, 20260
0
0 solved
A warehouse floor plan grid uses 'S' for shelving and 'O' for open floor. Open cells that cannot reach the outer edge of the floor through other open cells (4-directionally) are enclosed dead zones; convert every enclosed 'O' to 'S' in place.
An Amazon technical screen grid question framed around finding unreachable dead space when planning robot drive paths in a fulfillment center. The interviewer looks for the border-first insight: flood fill from edge open cells to mark safe ones, then flip everything else.
What the Interviewer Expects
- Realize enclosed means not connected to any border open cell
- Flood fill from every border 'O' rather than from interior cells
- Use a temporary marker for cells that reach the edge
- Flip remaining 'O' cells and restore marked ones
- Use iterative BFS to avoid recursion limits on large plans
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
- Return the size of each enclosed zone instead of filling it.
- What if diagonal moves are allowed for robots?
- How would you recompute after a single shelf is removed?
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: a list of lists of characters 'S' and 'O', possibly empty. Modify it in place so every 'O' not connected to the border becomes 'S'. Return nothing (the function returns the grid only fo...
High-Level Design
Searching from each interior cell to see if it escapes is wasteful, since many searches overlap. Flip the question: an open cell is safe exactly when it is connected to some open cell on the border. S...