LeetCode 850. Rectangle Area II


LeetCode题解专栏:LeetCode题解
我做的所有的LeetCode的题目都放在这个专栏里,大部分题目Java和Python的解法都有。


We are given a list of (axis-aligned) rectangles. Each rectangle[i] = [x1, y1, x2, y2] , where (x1, y1) are the coordinates of the bottom-left corner, and (x2, y2) are the coordinates of the top-right corner of the ith rectangle.

Find the total area covered by all rectangles in the plane. Since the answer may be too large, return it modulo 10^9 + 7.

LeetCode 850. Rectangle Area II

Example 1:

Input: [[0,0,2,2],[1,0,2,3],[1,0,3,1]]
Output: 6
Explanation: As illustrated in the picture.

Example 2:

Input: [[0,0,1000000000,1000000000]]
Output: 49

Explanation: The answer is 10^18 modulo (10^9 + 7), which is (10^9)^2 = (-7)^2 = 49.

Note:

  • 1 <= rectangles.length <= 200
  • rectanges[i].length = 4
  • 0 <= rectangles[i][j] <= 10^9
  • The total area covered by all rectangles will never exceed 2^63 - 1 and thus will fit in a 64-bit signed integer.

相关文章:

  • 2021-12-07
  • 2022-02-28
  • 2021-07-23
  • 2021-07-30
  • 2022-03-05
  • 2022-01-22
  • 2021-06-28
猜你喜欢
  • 2022-12-23
  • 2021-12-12
  • 2021-09-13
  • 2021-12-02
  • 2022-12-23
  • 2021-10-21
  • 2021-09-30
相关资源
相似解决方案