首页 > 其他 > 详细

[LeetCode] 850. Rectangle Area II 矩形面积之二

时间:2019-08-18 11:20:52      阅读:257      评论:0      收藏:0      [点我收藏+]



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.

技术分享图片

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.



Github 同步地址:

https://github.com/grandyang/leetcode/issues/850



类似题目:

Rectangle Area



参考资料:

https://leetcode.com/problems/rectangle-area-ii/



LeetCode All in One 题目讲解汇总(持续更新中...)

[LeetCode] 850. Rectangle Area II 矩形面积之二

原文:https://www.cnblogs.com/grandyang/p/11371256.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!