Largest Rectangular Free Region on a Datacenter Floor Plan

Last updated: November 29, 2026

Quick Overview

A datacenter floor is a binary grid where 1 marks an occupied tile (rack, pillar, cable tray) and 0 marks a free tile. Return the area of the largest axis-aligned rectangle made only of free tiles, where new hardware could be placed.

Microsoft
Coding & Algorithms
Software Engineer
Microsoft
November 29, 2026
Software Engineer
Onsite
Coding & Algorithms
Hard

0

0

0 solved


A datacenter floor is a binary grid where 1 marks an occupied tile (rack, pillar, cable tray) and 0 marks a free tile. Return the area of the largest axis-aligned rectangle made only of free tiles, where new hardware could be placed.

This is a well known hard grid question that Microsoft onsites use for Azure infrastructure flavored loops. The interviewer expects you to reduce the grid to a histogram per row and solve each histogram with a monotonic stack.

What the Interviewer Expects
  • Reduce each row to a histogram of consecutive free tiles above
  • Solve largest rectangle in a histogram with a monotonic stack
  • Explain how the popped bar's width is computed from neighbors
  • Achieve O(rows * cols) overall
  • Test on a grid with no free tiles and a fully free grid
Key Topics to Cover
monotonic stack
histogram
matrix
dynamic programming
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
  • What if you need the largest free square instead?
  • How would you report the rectangle's coordinates?
  • How would you handle frequent single tile updates without rescanning the whole floor?
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: grid of 0 (free) and 1 (occupied), possibly empty.
  • Output: area of the largest all-free rectangle.
  • Rectangles are axis aligned and made of whole tiles....
High-Level Design

Fix a bottom row r. For each column c, let heights[c] be the number of consecutive free tiles ending at row r in that column. Any free rectangle whose bottom edge is on row r is a rectangle under th...


Submit Your Answer
Markdown supported