Practice Rectangle Area II
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
You are given a 2D array of axis-aligned rectangles. Each rectangle[i] = [xi1, yi1, xi2, yi2] denotes the ith rectangle where (xi1, yi1) are the coordinates of the bottom-left corner, and (xi2, yi2) are the coordinates of the top-right corner. Calculate the total area covered by all rectangles in the plane. Any area covered by two or more rectangles should only be counted once. Return the total area. Since the answer may be too large, return it modulo 10^9 + 7.
Source: Rectangle Area II on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
rectangles = [[0,0,2,2],[1,0,2,3],[1,0,3,1]]
6
# Example 2
rectangles = [[0,0,1000000000,1000000000]]
49
Constraints
Related LeetCode Problems
Practice more problems similar to Rectangle Area II.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.