Determine whether two axis-aligned rectangles overlap with positive area.
You are given two axis-aligned rectangles in the 2D plane. Each rectangle is described by the coordinates of its bottom-left corner and top-right corner.
Return whether the two rectangles overlap with positive area. Touching at an edge or a corner does not count as overlap.
A rectangle is represented as [x1, y1, x2, y2] where:
(x1, y1) is the bottom-left corner(x2, y2) is the top-right cornerx1 < x2 and y1 < y2Two axis-aligned rectangles overlap if and only if they overlap on both the x-axis and the y-axis with a strictly positive intersection length.
rec1 and rec2[x1, y1, x2, y2]true if the rectangles overlap with positive areafalserec1.length == rec2.length == 4x1 < x2 and y1 < y2 for each rectangleExample 1
Input
rec1 = [0,0,2,2], rec2 = [1,1,3,3]
Output
true
Explanation
The rectangles share a 1x1 area in the middle.
Example 2
Input
rec1 = [0,0,1,1], rec2 = [1,1,2,2]
Output
false
Explanation
They only meet at one corner, so the overlap area is zero.
Premium problem context
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.