Leetcode: Rectangle Area
来源:互联网 发布:手机我的世界枪械js 编辑:程序博客网 时间:2024/04/30 18:14
Question
Find the total area covered by two rectilinear rectangles in a 2D plane.
Each rectangle is defined by its bottom left corner and top right corner as shown in the figure.
Rectangle Area
Assume that the total area is never beyond the maximum possible value of int.
Credits:
Special thanks to @mithmatt for adding this problem, creating the above image and all test cases.
Show Tags
Solution
Analysis
The coordination of the corner node of the intersection area is the the min and max of those coordinations.
Code
class Solution(object): def computeArea(self, A, B, C, D, E, F, G, H): """ :type A: int :type B: int :type C: int :type D: int :type E: int :type F: int :type G: int :type H: int :rtype: int """ return (C-A)*(D-B) + (G-E)*(H-F) - max(0,min(C,G)-max(E,A))*max(0,min(D,H)-max(F,B))
0 0
- leetcode Rectangle Area
- [LeetCode] Rectangle Area
- leetcode--Rectangle Area
- [LeetCode]Rectangle Area
- [leetcode] Rectangle Area
- Rectangle Area - LeetCode 223
- leetcode-Rectangle Area[math]
- leetCode 之 Rectangle Area
- leetcode 223: Rectangle Area
- [leetcode]Rectangle Area
- leetcode[223]:Rectangle Area
- LeetCode Rectangle Area
- [leetcode][math] Rectangle Area
- #leetcode#Rectangle Area
- [LeetCode] Rectangle Area
- LeetCode: Rectangle Area
- Leetcode 223 Rectangle Area
- [Leetcode]-Rectangle Area
- CAShapeLayer绘制环形进度条
- Storyboard (<UIStoryboard: 0x15e989a0>) doesn't contain a view controller with identifier "***C"
- PS学习工具----魔术棒工具
- Android 数据存储---SharedPreference
- IOS设计模式一:代理模式
- Leetcode: Rectangle Area
- java笔记一
- android自定义控件学习笔记
- 【bzoj1968】【Ahoi2005】【COMMON 约数研究】【循环】
- 开博
- Make 简要教程及整理 --- 第一篇
- 《算法导论》的桶排序C++实现
- json数据传递新手入门
- PHP MySQL乱码终极解决方案