This is a verified interview question from Walmart. Candidates reporting seeing this problem in recent Online Assessments (OAs) and onsite rounds. Mastering "Rectangle Area II" covers key patterns like Other.
"### Problem You are given a 2D array of axis-aligned rectangles. Each rectangle[i] = [x1, y1, x2, y2] denotes the ith rectangle where (x1, y1) are the coordinates of the bottom-left corner, and (x2, y2) 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. ### Input - rectangles = [[x1, y1, x2, y2], ...] ### Output - Total area covered by all rectangles modulo 10^9 + 7 ### Example 1: Input: rectangles = [[0,0,2,2],[1,0,2,3],[1,0,3,1]] Output: 6 ### Example 2: Input: rectangles = [[0,0,1000000000,1000000000]] Output: 49"
Join thousands of developers practicing for Walmart.