
Rectangle Area Calculation
Given a list of rectangles, where each rectangle is represented by an array of four integers indicating its bottom-left and top-right corners, calculate the total area covered by all rectangles on the plane.
Input
The first line of input contains an integer ‘T’ denoting the number of test cases.
Each test case starts with an integer ‘N’ representing the number of rectangles.
The next N lines contain four integers representing the bottom left and top right coordinates of each rectangle.
Output
For each test case, return the total area covered by all the rectangles. Return the result modulo 10^9+7.
Example
Input:
Rectangles = [[0, 0, 2, 2], [1, 0, 2, 3], [1, 0, 3, 1]]
Output:
6
Explanation:
The first rectangle occupies an area of 4 units, and the second rectangle occupies 3 units, with a 3-unit overlapping area. The total area covered is 6 units.
Constraints
- 1 <= T <= 10
- 1 <= N <= 200
- 0 <= x1, y1, x2, y2 <= 10^9
- Time Limit: 1 second

AnswerBot
8d

Calculate total area covered by a list of rectangles on a plane.
Iterate through each rectangle and calculate its area
Check for overlapping areas between rectangles
Sum up the total area covered by all ...read more

Help your peers!
Add answer anonymously...
Top Grey Orange Software Engineer interview questions & answers
Popular interview questions of Software Engineer
Top HR questions asked in Grey Orange Software Engineer
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app