Total Footprint Area of Overlapping Floor Plan Rectangles
Last updated: November 29, 2026
Quick Overview
Given up to tens of thousands of axis-aligned rectangles representing rooms, slabs, or zones in a floor plan, compute the total area they cover, counting overlapping regions only once.
Autodesk
November 29, 20260
0
0 solved
Given up to tens of thousands of axis-aligned rectangles representing rooms, slabs, or zones in a floor plan, compute the total area they cover, counting overlapping regions only once.
Area takeoffs are a core workflow in Revit, AutoCAD and Forma site planning, and overlapping zones are the norm. This is a harder onsite problem that tests sweep line thinking, coordinate compression and a segment tree that tracks covered length.
What the Interviewer Expects
- Reject the grid-rasterization approach for real-valued coordinates
- Sweep a vertical line over x events (enter and exit)
- Compress y coordinates into elementary intervals
- Maintain covered y length with a segment tree storing a cover count and covered length
- Accumulate covered length times x gap between events
- Analyze O(n log n)
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
- Why does this segment tree not need lazy propagation?
- How would you extend this to rotated rectangles or arbitrary polygons?
- How would you report area per room after subtracting overlaps with higher priority zones?
- What changes for exact arithmetic with very large coordinates?
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: rectangles (x1, y1, x2, y2). Output: the area of their union. Degenerate rectangles contribute nothing. n can be large, so O(n^2) pairwise inclusion-exclusion is out, and rasterizing to a gri...
High-Level Design
Sweep a vertical line left to right. Each rectangle produces an enter event at x1 and an exit event at x2, both carrying its y span. Between consecutive event x values the covered y length is constant...