- It’s easy to get areas of
- How to find their overlapped area?
widthfor example, if they are overlapped, then
Math.min(ax2, bx2) - Math.max(ax1, bx1) > 0. Otherwise it’s negative.
Given the coordinates of two
rectilinear rectangles in a 2D plane, return the total area covered by the two rectangles.
The first rectangle is defined by its
bottom-left corner (ax1, ay1) and its
The second rectangle is defined by its
bottom-left corner (bx1, by1) and its
Input: ax1 = -3, ay1 = 0, ax2 = 3, ay2 = 4, bx1 = 0, by1 = -1, bx2 = 9, by2 = 2