rects[i] = [x1, y1, x2, y2] has its bottom-left corner at (x1, y1) and its top-right corner at (x2, y2).
Find the total area they cover. Any region covered by more than one rectangle counts only once.
The answer can be very large, so return it modulo 10⁹ + 7.rects=[[0, 0, 4, 2], [2, 1, 5, 4]] → 15
The areas are 8 and 9; the shared piece from (2, 1) to (4, 2) has area 2 and counts once: 8 + 9 - 2 = 15.
rects=[[1, 1, 3, 3], [0, 0, 6, 6]] → 36
The small rectangle lies entirely inside the big one, so the answer is the big one's area, 36.
rects=[[0, 0, 100000, 100000]] → 999999937
The area 10¹⁰ is taken modulo 10⁹ + 7.
rects=[[0, 0, 4, 2], [2, 1, 5, 4]]
15
Run checks the first 3 tests in your browser. Submit checks all 97 tests on the server, hidden ones included.