850. Rectangle Area II
Practice Rectangle Area II for free on NudgeCode: Hard, Array & Hash Table pattern. Write it in Python or JavaScript, run the tests in your browser, and ask for a hint when you are stuck.
Each rectangles[i] = [x1, y1, x2, y2] is an axis-aligned rectangle with bottom-left corner (x1, y1) and top-right corner (x2, y2). Return the total area covered by the union of all rectangles (area covered more than once counts once), modulo 10^9 + 7.
Example
rectangles = [[0,0,2,2],[1,0,2,3],[1,0,3,1]] -> 6
rectangles = [[0,0,1000000000,1000000000]] -> 49
(10^18 mod (10^9 + 7) = 49.)
Constraints
- 1 <= rectangles.length <= 200
- 0 <= x1 <= x2 <= 10^9, 0 <= y1 <= y2 <= 10^9