The Rectangle Overlap problem asks whether two axis-aligned rectangles overlap (share any positive area). Two rectangles overlap if their x-ranges and y-ranges both intersect with positive length. This easy coding problem tests concise geometric condition evaluation. The math and geometry interview pattern is demonstrated.
Microsoft, Meta, Amazon, Google, and Adobe ask this as a geometry warm-up. It tests the ability to express the overlap condition concisely: two rectangles overlap if and only if they don't NOT overlap in either dimension.
Non-overlap complement. Rectangles do NOT overlap if: rec2[0] >= rec1[2] (rec2 is to the right), OR rec2[2] <= rec1[0] (rec2 is to the left), OR rec2[1] >= rec1[3] (rec2 is above), OR rec2[3] <= rec1[1] (rec2 is below). Return NOT of these conditions.
Or equivalently: overlap iff rec1[0] < rec2[2] AND rec2[0] < rec1[2] AND rec1[1] < rec2[3] AND rec2[1] < rec1[3].
rec1=[0,0,2,2], rec2=[1,1,3,3].
rec1=[0,0,1,1], rec2=[1,0,2,1]. x: 0 < 2 ✓ but 1 < 1? No → false (adjacent, not overlapping).
Rectangle Overlap uses the non-overlap complement pattern: it's easier to check when they DON'T overlap (one is entirely left/right/above/below) than when they do. The complement of 4 non-overlap conditions gives overlap. Memorize the strict inequality condition: overlap requires strictly overlapping intervals in BOTH dimensions. Practice with touching rectangles (they don't count as overlapping per this strict definition).
| Title | Difficulty | Topics | LeetCode |
|---|---|---|---|
| Minimum Cuts to Divide a Circle | Easy | Solve | |
| Rectangle Area | Medium | Solve | |
| Circle and Rectangle Overlapping | Medium | Solve | |
| Valid Square | Medium | Solve | |
| Minimum Time Visiting All Points | Easy | Solve |