Compute Drawing Extents Across Visible Layers
Last updated: November 29, 2026
Quick Overview
Given a list of 2D drawing entities (lines, polylines, circles), each on a named layer, return the axis-aligned bounding box of everything on visible layers, the box a Zoom Extents command would fit to the screen.
Autodesk
November 29, 20260
0
0 solved
Given a list of 2D drawing entities (lines, polylines, circles), each on a named layer, return the axis-aligned bounding box of everything on visible layers, the box a Zoom Extents command would fit to the screen.
A warm-up in the style of an AutoCAD or AutoCAD Web phone screen. The interviewer wants clean handling of heterogeneous entity types, correct extents for curved geometry (a circle is not its center), and sensible behavior when nothing is visible.
What the Interviewer Expects
- Dispatch per entity type to compute each entity's own bounds
- Treat a circle as center plus or minus radius on both axes
- Skip entities on hidden layers
- Return a clear sentinel when no visible entity exists
- Single pass, O(n) over total points
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
- How would you bound an arc that spans only part of a circle?
- How would you keep extents up to date as entities are added, moved, or deleted without a full rescan?
- What changes if entities carry a transform, such as a rotated block reference?
- How would you add padding so the zoomed view does not touch the screen edge?
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: entities like {"type": "circle", "center": (x, y), "radius": r, "layer": "WALLS"} plus a set of hidden layer names. Output: (min_x, min_y, max_x, max_y) or None if nothing is visible. I w...
High-Level Design
Split the problem in two: a per-entity entity_bounds that knows each geometry type, and an aggregator that unions boxes. This mirrors how a real CAD database works: each entity class reports its own...