Detect Overlapping Furniture in a Room Planner Layout

Last updated: November 29, 2026

Quick Overview

Given room dimensions and a list of furniture pieces as axis-aligned rectangles (name, x, y, width, depth), return the pieces that extend outside the room and every pair of pieces whose footprints overlap. Pieces that only touch along an edge are allowed.

Wayfair
Coding & Algorithms
Frontend Engineer
Wayfair
November 29, 2026
Frontend Engineer
Phone Screen
Coding & Algorithms
Easy

0

0

0 solved


Given room dimensions and a list of furniture pieces as axis-aligned rectangles (name, x, y, width, depth), return the pieces that extend outside the room and every pair of pieces whose footprints overlap. Pieces that only touch along an edge are allowed.

Wayfair's room planner and 3D View in Room features let shoppers drop sofas, rugs and tables into a floor plan, and the client has to warn when a layout is impossible. A phone screen at this level checks that you get rectangle intersection exactly right (strict versus touching), and that you can improve on the obvious all-pairs loop.

What the Interviewer Expects
  • States the strict overlap condition on both axes correctly
  • Handles touching edges as non-overlapping
  • Checks room bounds separately from pairwise overlap
  • Uses a sort by left edge to prune comparisons
  • Discusses rotated pieces as a follow-up rather than ignoring them
Key Topics to Cover
rectangle intersection
sweep line
sorting
geometry edge cases
room planner
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
  • How would you support pieces rotated by 90 degrees, or by arbitrary angles?
  • A rug is meant to sit under a coffee table. How would you model layers so that is not flagged?
  • The layout has 5,000 pieces in a commercial floor plan. What structure makes this fast?
  • How would you also enforce a minimum walking clearance of 18 inches between pieces?
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: room width and depth, plus pieces (name, x, y, w, d) with (x, y) the lower-left corner in inches. Output: names of pieces not fully inside the room, and pairs of pieces whose interiors inte...

High-Level Design

Two independent checks.

  1. Bounds: a piece is outside if x < 0, y < 0, x + w > W or y + d > D.
  2. Overlap: rectangles A and B overlap iff their x-intervals and y-intervals both overla...

Submit Your Answer
Markdown supported

Related Questions