Largest Square of Open Floor Space in a Fulfillment Center

Last updated: November 29, 2026

Quick Overview

A fulfillment center floor plan is a grid where "." is open and "#" is occupied by racks; return the side length of the largest square region made entirely of open cells.

Amazon
Coding & Algorithms
Software Engineer
Amazon
November 29, 2026
Software Engineer
Onsite
Coding & Algorithms
Medium

0

0

0 solved


A fulfillment center floor plan is a grid where "." is open and "#" is occupied by racks; return the side length of the largest square region made entirely of open cells.

When Amazon reconfigures a building, planners need contiguous open space for new equipment. This onsite DP checks the min-of-three-neighbors recurrence and a clear explanation of why it is correct.

What the Interviewer Expects
  • Define side[r][c] as the largest open square with bottom-right corner (r, c)
  • Recurrence 1 + min(top, left, top-left)
  • Track the global max
  • Use a padded rolling row
  • O(R * C) time
Key Topics to Cover
2D dynamic programming
maximal square
grid
space optimization
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
  • Return the area of the largest open rectangle instead.
  • How would you count all open squares?
  • What if some cells become occupied over time and you must answer queries?
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: list of equal-length strings. Output: side length of the largest all-open square (0 if none)....

High-Level Design

Let side[r][c] be the side of the largest open square whose bottom-right corner is (r, c). If the cell is occupied it is 0. Otherwise the square is limited by the squares ending at the top, left, an...


Submit Your Answer
Markdown supported