Search⌘ K
AI Features

Check if Rectangles Overlap

Explore the method to check if two axis-aligned rectangles overlap by comparing their bottom-left and top-right coordinates. Understand the logic behind why touching edges or corners do not count as overlap and learn a constant time algorithm to return accurate results efficiently.

Statement

Given the bottom-left and top-right coordinates of two axis-aligned rectangles, check if the two rectangles overlap. Return true if they overlap, otherwise, return false.

Note: Two rectangles that only touch at the corner or edges do not overlap.

Example

In the following example, we have two overlapping rectangles: Rectangle1 and Rectangle2.

Sample input

Rectangle1 = [0, 0, 2, 2]
Rectangle2 = [1, 1, 3, 3]
...