Grokking Oracle Coding Interview
Ask Author
Back to course home

0% completed

Solution: Rectangle Overlap

Problem Statement

You are given a rectangle as a list [x1, y1, x2, y2], where (x1, y1) is the coordinate of its bottom-left corner, and (x2, y2) is the coordinate of its top-right corner. The top and bottom edges of the rectangle are parallel to the X-axis, and the left and right edges are parallel to the Y-axis.

Two rectangles overlap if the rectangles share a part of the area; mere touching at edges or corners doesn't count.

Given two rectangles rec1 and rec2, return true if they overlap, otherwise return false.

Examples

  • Example 1:

.....

.....

.....

Like the course? Get enrolled and start learning!