FunctionRacerProblemsRace

Area of Two Rectangles

EasyMathPython, JavaScript, TypeScript, Java, C++

Each rectangle is [x1, y1, x2, y2] (bottom left and top right corners, sides parallel to the axes). Return the total area covered by the two rectangles together, counting any shared region only once.

Example 1

r1 [0,0,3,3]
r2 [2,2,4,4]
returns 12

9 + 4 - 1 = 12.

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