FunctionRacerProblemsRace

Rectangle Overlap

EasyMathPython, JavaScript, TypeScript, Java, C++

A rectangle is given as [x1, y1, x2, y2]: its bottom left corner (x1, y1) and top right corner (x2, y2), with sides parallel to the axes. Return True if the two rectangles share some area bigger than zero. Rectangles that only touch along an edge or at a corner do not overlap.

Example 1

r1 [0,0,2,2]
r2 [1,1,3,3]
returns true

They share the square from (1,1) to (2,2).

Example 2

r1 [0,0,1,1]
r2 [1,0,2,1]
returns false

They only touch along an edge.

Constraints

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More Math problems